Auto implement function stubs
Project description
Magic Stubs
Magic Stubs implements your functions for you.
Demo
https://github.com/user-attachments/assets/f4d0fb4e-3b24-41d6-87ee-ff5931341219
Technology
MagicStubs.py uses a combination of abusing source code encodings, LLM calls, and AST rewriting so you don't have to bother writing code.
Installation
pip install magic_stubs
export OPENAI_API_KEY=...
Usage
Add # coding: magic_stubs
to the top of your python file. Then execute as normal. Magic Stubs will automatically fill in your function definitions where needed.
hello_world.py:
# coding: magic_stubs
def print_hello_world():
pass
print_hello_world()
$ python3 hello_world.py
Hello, World!
Examples
FizzBuzz
$ cat examples/fizzbuzz.py
# coding: magic_stubs
def fizzbuzz(n):
pass
print(' '.join([fizzbuzz(n) for n in range (1, 21)]))
$ python3 examples/fizzbuzz.py
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz
Mandelbrot Set
$ cat examples/mandelbrot.py
# coding: magic_stubs
def get_string_representation_of_mandelbrot_set():
pass
print(get_string_representation_of_mandelbrot_set())
$ python3 examples/mandelbrot.py
***
******
*****
** *************
***********************
* ************************
***************************
****************************
******** ******************************
************ ******************************
******************************************
*************************************************************
******************************************
************ ******************************
******** ******************************
****************************
***************************
* ************************
***********************
** *************
*****
******
***
Attribution
Inspired by and using Tsche's magic_codec.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
magic_stubs-0.1.tar.gz
(4.6 kB
view details)
Built Distribution
File details
Details for the file magic_stubs-0.1.tar.gz
.
File metadata
- Download URL: magic_stubs-0.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a777c7d2eb278027e99f9845b8763e41b7791aaa8648c7f2608eda67f73eeb27 |
|
MD5 | 6297335de0e57df80f15a55230c76d72 |
|
BLAKE2b-256 | 5b4f7295f4bf935402bca8d4399a1362c3d1642db36472b245c863ad995e3791 |
File details
Details for the file magic_stubs-0.1-py3-none-any.whl
.
File metadata
- Download URL: magic_stubs-0.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff5806f919d00823c91d6e4af62d26323f82b81eb4fb65d22d381fe053397513 |
|
MD5 | 328997c23cac477713b40d1da581808a |
|
BLAKE2b-256 | 86feb636e63425994223da92ef56fe53349f0cf9f129c2f8f1383f06043ec286 |