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.2.0
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymender-0.2.0.tar.gz.
File metadata
- Download URL: pymender-0.2.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
101bd7adf14ea98ede73ef34a76b1a9e2bb77ff59cdc182ba84837a619f617f8
|
|
| MD5 |
6f235e0faa67b4d405d65e568ad370cc
|
|
| BLAKE2b-256 |
96cd4cce24b78e351d9a4c821324db18c180365b10dd00074589a75f849f15ec
|
File details
Details for the file pymender-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pymender-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.0 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 |
6e87bd8a84d3d8a54406878edb7776a6c0deb66ed5d581dc1d8e25ee9d361964
|
|
| MD5 |
bec4f9635f2321d9e80d94b6b22cbace
|
|
| BLAKE2b-256 |
686e81e3aac18379dba845994114c2437b5655b223bbfbf78d1e9dd38e60b6cb
|