
Security News
Open Source Maintainers Demand Ability to Block Copilot-Generated Issues and PRs
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Allows users to write composable assert
s that are not stripped away in optimized mode.
safe_assert
is a function, it can be easily composed with other functionspip install safe-assert
The usage is identical to assert
keyword, but a function:
from safe_assert import safe_assert
def sort_positive_numbers(numbers: List[int]) -> List[int]:
safe_assert(all(num >= 0 for num in numbers), 'found negative')
return sorted(numbers)
sort_positive_numbers([1, 2, 3]) # => will work
sort_positive_numbers([-1, 2, 3])
# => will fail in runtime with `AssertionError`
How is it different from regular assert
?
The major one is that it would not be stripped away with -O
flag.
So, it still allows to write declarative checks that are safe in production.
The second one is that you can compose it as any other regular function.
Useful in conjunction with dry-python
projects.
How does it work internally?
It internally raises AssertionError
that is also used by the assert
keyword itself.
See docs to learn more.
MIT.
FAQs
Safe assert for Python that can be used together with optimised mode
We found that safe-assert 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
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Research
Security News
Malicious Koishi plugin silently exfiltrates messages with hex strings to a hardcoded QQ account, exposing secrets in chatbots across platforms.
Research
Security News
Malicious PyPI checkers validate stolen emails against TikTok and Instagram APIs, enabling targeted account attacks and dark web credential sales.