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)
Metadata
Release files for py-code-cleaner 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_code_cleaner-1.3.0.tar.gz | 7.9 kB | Without provenance | Details for py_code_cleaner-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_code_cleaner-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for py_code_cleaner-1.3.0-py3-none-any.whl |
Total release size: 16.8 kB
Release files / py_code_cleaner-1.3.0.tar.gz
| Download URL | py_code_cleaner-1.3.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f561b803e7a15fe327232ec2ae291c5b4e696bf1804ec146bb688beea2d97eb
|
|
BLAKE2b-256 checksum How to use checksums |
e9b63483006d259b0f2e6522af319bd2f0ba42ddbccba5feda3d9041acabbb84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.21
|
Release files / py_code_cleaner-1.3.0-py3-none-any.whl
| Download URL | py_code_cleaner-1.3.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dfdf4b3ac595d4dc03ffeb5daa88aa9033ec5f1e97cf65f0f0e19eeb15dd35f1
|
|
BLAKE2b-256 checksum How to use checksums |
a83180844dd5a8123dc98550a1089a58653036a056e8e4d00713af3715eefa81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.21
|
Security for py-code-cleaner 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.