
Security News
NVD Quietly Sweeps 100K+ CVEs Into a “Deferred” Black Hole
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Inspired by this blog post. I described the building process of this tool here.
“For those who like dinosaurs 🦖 and clean try/except ✨ blocks.”
Summary
pip install tryceratops
OR
poetry add -D tryceratops
tryceratops [filename or dir...]
You can enable experimental analyzers by running:
tryceratops --experimental [filename or dir...]
You can ignore specific violations by using: --ignore TRYXXX
repeatedly:
tryceratops --ignore TRY201 --ignore TRY202 [filename or dir...]
You can exclude dirs by using: --exclude dir/path
repeatedly:
tryceratops --exclude tests --exclude .venv [filename or dir...]
You can also autofix some violations:
tryceratops --autofix [filename or dir...]
flake8
Plugin🦖 Tryceratops is also a plugin for flake8
, so you can:
❯ flake8 --select TRY src/tests/samples/violations/call_raise_vanilla.py
src/tests/samples/violations/call_raise_vanilla.py:13:9: TRY002 Create your own exception
src/tests/samples/violations/call_raise_vanilla.py:13:9: TRY003 Avoid specifying long messages outside the exception class
src/tests/samples/violations/call_raise_vanilla.py:21:9: TRY201 Simply use 'raise' without specifying exception object again
All violations and its descriptions can be found in docs.
So far, autofix only supports violations: TRY200, TRY201, and TRY400.
If you want to ignore a violation in a specific file, you can either:
noqa
to the top of the file you want to ignorenoqa
to the line you want to ignorenoqa: CODE
to the line you want to ignore a specific violationExample:
def verbose_reraise_1():
try:
a = 1
except Exception as ex:
raise ex # noqa: TRY202
You can set up a pyproject.toml
file to set rules.
This is useful to avoid reusing the same CLI flags over and over again and helps to define the structure of your project.
Example:
[tool.tryceratops]
exclude = ["samples"]
ignore = ["TRY002", "TRY200", "TRY300"]
experimental = false
check_pickable = false
allowed_base_exceptions = ["MyAppBase"]
CLI flags always overwrite the config file.
If you wish to use pre-commit, add this:
- repo: https://github.com/guilatrova/tryceratops
rev: v2.4.1
hooks:
- id: tryceratops
Add this fancy badge to your project's README.md
:
[](https://github.com/guilatrova/tryceratops)
If you want to read more about:
Thank you for considering making Tryceratops better for everyone!
Refer to Contributing docs.
See CHANGELOG.
MIT
Thanks to God for the inspiration 🙌 ☁️ ☀️
The black project for insights.
FAQs
Prevent Exception Handling AntiPatterns
We found that tryceratops demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD now marks all pre-2018 CVEs as "Deferred," signaling it will no longer enrich older vulnerabilities, further eroding trust in its data.
Research
Security News
Lazarus-linked threat actors expand their npm malware campaign with new RAT loaders, hex obfuscation, and over 5,600 downloads across 11 packages.
Security News
Safari 18.4 adds support for Iterator Helpers and two other TC39 JavaScript features, bringing full cross-browser coverage to key parts of the ECMAScript spec.