Mend your Python projects with reproducible refactors
Project description
👷♀️ PyMender
Perform entire codebase refactors in a way that is reproducible, testable and reviewable. Obeys .gitignore
by default.
Usage
pip install pymender==0.1.2
pymender <codemod> <path_to_project>
What codemods are available?
⚡ FastAPIAnnotated
Converts FastAPI endpoints to use the preferred Annotated[<type>, Depends(<dependency>)]
syntax rather than : <type> = Depends(<dependency>)
.
Why?
- Default value of the function parameter is the actual default value.
- Reuse of the function is now possible.
- Type-safe usage of the functions, previously 'default' values where not type checked.
- Multi-purpose e.g.
Annotated[str, fastapi.Query(), typer.Argument()]
is now possible.
pymender FastAPIAnnotated <folder-to-upgrade>
Before | After |
---|---|
@router.get('/example') |
@router.get('/example') |
Developer Guide
# Run a particular codemod
python3 -m pymender <codemod> <path_to_project>
# e.g.
python3 -m pymender FastAPIAnnotated <path_to_project>
# Run the codemod directly
python3 -m libcst.tool codemode fastapi_annotated.FastAPIAnnotated <path_to_project>
# Run tests
pytest -vv
Thanks to:
- libCST which does a lot of the hardwork for this.
- autotyping for showing what was possible.
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
pymender-0.1.2.tar.gz
(6.6 kB
view details)
Built Distribution
File details
Details for the file pymender-0.1.2.tar.gz
.
File metadata
- Download URL: pymender-0.1.2.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd727de174cb6930a1d0d75e181cf4824f29d9183f3ea794872e54e37a6f904f |
|
MD5 | d86238a6a159014738982253ec8f9ef0 |
|
BLAKE2b-256 | 197f1735630939ae6c0493732347b71a455d59fc10fc63462bd3aa5683e785ac |
File details
Details for the file pymender-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: pymender-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4af295bd7cb8c7e8593c79f7886626c495b0e17246c55aa046dc8c4080ac64c3 |
|
MD5 | 93e2c0719cdea60677b58a4b61ca843a |
|
BLAKE2b-256 | 119e08dbdf6e77349e07bfebee2110d763ffe8ef99027c97b3106752c0ca2991 |