Small PyPI package which provides python code cleaning from comments, docstrings, annotations
Project description
py-code-cleaner
Small PyPI package provides python code cleaning from comments, docstrings, annotations. Primary I use it for automated checks whether no code in the python files has been changed whatever new lines or comments added.
pip install py-code-cleaner
from py_code_cleaner import clean_py, clean_py_deep, clean_py_main
# def clean_py_main(
# src: PathLike,
# dst: Optional[PathLike] = None,
# keep_nonpy: Optional[Iterable[str]] = ('.pyx',),
# filter_empty_lines: bool = True,
# filter_docstrings: bool = True,
# filter_annotations: bool = True,
# quiet: bool = False,
# dry_run: bool = False
# )
CLI
clean-py
clean-py -h
usage: clean-py [-h] [--destination DESTINATION] [--keep-nonpy KEEP_NONPY [KEEP_NONPY ...]] [--keep-empty-lines] [--keep-docstrings] [--keep-annotations] [--quiet] [--dry-run] source
Cleanses *.py files from comments, empty lines, annotations and docstrings
positional arguments:
source python file path or path to directory with files
optional arguments:
-h, --help show this help message and exit
--destination DESTINATION, -d DESTINATION
destination file or directory; empty means to print to stdout (default: None)
--keep-nonpy KEEP_NONPY [KEEP_NONPY ...], -k KEEP_NONPY [KEEP_NONPY ...]
additional file extensions to transfer between src and dst directories (to not ignore) (default: )
--keep-empty-lines, -e
Whether to not remove empty lines (default: False)
--keep-docstrings, -s
Whether to not remove docstrings (default: False)
--keep-annotations, -a
Whether to not remove annotations (default: False)
--quiet, -q Do not print processing info (default: False)
--dry-run, -n Whether to run without performing file processing operations (default: False)
clean-py-many
clean-py-many --help
usage: clean-py-many [-h] --destination DESTINATION [--keep-nonpy KEEP_NONPY [KEEP_NONPY ...]] [--keep-empty-lines] [--keep-docstrings] [--keep-annotations] [--quiet] [--dry-run] sources [sources ...]
Cleans *.py files from comments, empty lines, annotations and docstrings
positional arguments:
sources paths to python files or files directories to be cleaned; all results will be saved in destination directory with same relative names as in input;absolute paths will be cut to base names,
recommended to use relative paths
optional arguments:
-h, --help show this help message and exit
--destination DESTINATION, -d DESTINATION
destination directory (default: None)
--keep-nonpy KEEP_NONPY [KEEP_NONPY ...], -k KEEP_NONPY [KEEP_NONPY ...]
additional file extensions to transfer between src and dst directories (to not ignore) (default: )
--keep-empty-lines, -e
Whether to not remove empty lines (default: False)
--keep-docstrings, -s
Whether to not remove docstrings (default: False)
--keep-annotations, -a
Whether to not remove annotations (default: False)
--quiet, -q Do not print processing info (default: False)
--dry-run, -n Whether to run without performing file processing operations (default: False)
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 py_code_cleaner-1.3.0.tar.gz.
File metadata
- Download URL: py_code_cleaner-1.3.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f561b803e7a15fe327232ec2ae291c5b4e696bf1804ec146bb688beea2d97eb
|
|
| MD5 |
641d61d464ca8f8a701b66a8eb9c3fc0
|
|
| BLAKE2b-256 |
e9b63483006d259b0f2e6522af319bd2f0ba42ddbccba5feda3d9041acabbb84
|
File details
Details for the file py_code_cleaner-1.3.0-py3-none-any.whl.
File metadata
- Download URL: py_code_cleaner-1.3.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfdf4b3ac595d4dc03ffeb5daa88aa9033ec5f1e97cf65f0f0e19eeb15dd35f1
|
|
| MD5 |
e970e6c600ff2b2c1934209db7d242a7
|
|
| BLAKE2b-256 |
a83180844dd5a8123dc98550a1089a58653036a056e8e4d00713af3715eefa81
|