
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
.. image:: https://readthedocs.org/projects/class-namespaces/badge/?version=latest :target: http://class-namespaces.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status .. image:: https://travis-ci.org/mwchase/class-namespaces.svg?branch=master :target: https://travis-ci.org/mwchase/class-namespaces .. image:: https://coveralls.io/repos/github/mwchase/class-namespaces/badge.svg?branch=master :target: https://coveralls.io/github/mwchase/class-namespaces?branch=master .. image:: https://api.codacy.com/project/badge/Grade/f73ed5e3849c4049b8c9e3f17f6589da :target: https://www.codacy.com/app/max-chase/class-namespaces?utm_source=github.com&utm_medium=referral&utm_content=mwchase/class-namespaces&utm_campaign=Badge_Grade .. image:: https://codecov.io/gh/mwchase/class-namespaces/branch/master/graph/badge.svg :target: https://codecov.io/gh/mwchase/class-namespaces .. image:: https://landscape.io/github/mwchase/class-namespaces/master/landscape.svg?style=flat :target: https://landscape.io/github/mwchase/class-namespaces/master :alt: Code Health .. image:: https://scrutinizer-ci.com/g/mwchase/class-namespaces/badges/quality-score.png?b=master :target: https://scrutinizer-ci.com/g/mwchase/class-namespaces/?branch=master :alt: Scrutinizer Code Quality .. image:: https://scrutinizer-ci.com/g/mwchase/class-namespaces/badges/coverage.png?b=master :target: https://scrutinizer-ci.com/g/mwchase/class-namespaces/?branch=master :alt: Code Coverage .. image:: https://scrutinizer-ci.com/g/mwchase/class-namespaces/badges/build.png?b=master :target: https://scrutinizer-ci.com/g/mwchase/class-namespaces/build-status/master :alt: Build Status .. image:: https://codeclimate.com/github/mwchase/class-namespaces/badges/gpa.svg :target: https://codeclimate.com/github/mwchase/class-namespaces :alt: Code Climate .. image:: https://codeclimate.com/github/mwchase/class-namespaces/badges/coverage.svg :target: https://codeclimate.com/github/mwchase/class-namespaces/coverage :alt: Test Coverage .. image:: https://codeclimate.com/github/mwchase/class-namespaces/badges/issue_count.svg :target: https://codeclimate.com/github/mwchase/class-namespaces :alt: Issue Count
Well-behaved class namespacing in Python. Inspired by https://erezsh.wordpress.com/2008/06/27/namespaces-lets-do-more-of-those-python-hackery/
Example code::
import class_namespaces as cn
class MyCls(cn.Namespaceable):
var = 1
with cn.Namespace() as my_ns:
var = 2
assert MyCls.var == 1
assert MyCls.my_ns.var == 2
Other things that work:
Things that don't work:
Various ways of putting a Namespace in a Namespace that I didn't see an obvious way to handle. In particular...
Some pytest constructs behave weirdly inside the class definitions. Hopefully, this doesn't matter to anyone not writing tests for the package.
No way to have instance Namespaces on non-hashable types, or subclasses of some built-in types, particularly tuple. Try using data descriptors instead.
Things that might work:
FAQs
Class Namespaces
We found that class-namespaces 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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.