A CLI linter for Python that flags optimization and security issues
Project description
PyWard
PyWard is a lightweight command-line linter for Python code. It helps developers catch optimization issues (like unused imports and unreachable code) and security vulnerabilities (such as unsafe eval/exec usage and known CVE patterns).
Features
-
Optimization Checks
- Detects unused imports
- Flags unreachable code blocks
-
Security Checks
- Flags usage of
eval()andexec()(e.g., CVE-2025-3248) - Detects vulnerable imports like
python_json_logger(e.g., CVE-2025-27607)
- Flags usage of
-
Flexible CLI
- Run all checks by default
- Use
-o/--optimizeto run only optimization checks - Use
-s/--securityto run only security checks - Use
-v/--verbosefor detailed output, even if no issues are found
Installation
Install from PyPI:
pip install pyward-cli
Ensure that you have Python 3.7 or newer.
Usage
Basic usage (runs both optimization and security checks):
pyward <your_python_file.py>
Options
-
-o, --optimize
Run only optimization checks (unused imports, unreachable code). -
-s, --security
Run only security checks (unsafe calls, CVE-based rules). -
-v, --verbose
Show detailed warnings and suggestions, even if no issues are detected.
Examples
Run all checks on demo.py:
pyward demo.py
Run only optimization checks:
pyward -o demo.py
Run only security checks:
pyward -s demo.py
Run with verbose mode:
pyward -v demo.py
Contributing
Contributions are welcome! To add new rules or improve existing ones:
- Fork the repository.
- Create a new branch (e.g.,
feature/new-rule). - Implement your changes and add tests if applicable.
- Open a pull request detailing your enhancements.
Please adhere to the project’s coding style and include meaningful commit messages. For more details on the contributing process, see the CONTRIBUTING
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributors
|
Karan Vasudevamurthy |
cafewang |
DannyNavi |
REECK MONDAL |
Aydyn Maxadov |
Project details
Release history Release notifications | RSS feed
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 pyward_cli-0.1.6.tar.gz.
File metadata
- Download URL: pyward_cli-0.1.6.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
51a438303012ee95f148898579990430b45af4d0ecf936c0324935a86cd6ac0d
|
|
| MD5 |
0cd1172552d9ed1dece64c9aae68fa33
|
|
| BLAKE2b-256 |
bfb85c514f5b796b52df59b98b2342cc5edc0f05001cc2a0f8c8e2d6ac15832b
|
File details
Details for the file pyward_cli-0.1.6-py3-none-any.whl.
File metadata
- Download URL: pyward_cli-0.1.6-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c30778bcf651702e24c9718e6a073a98f323ac3e4ce97250f55606a1664dbcf3
|
|
| MD5 |
aa26678899c4ef8ea92c30a29bc7670b
|
|
| BLAKE2b-256 |
731b9faf6deb113486a450bf503b7ced1d73a7c1e92f8f8f41766ce35629e947
|