Skip to main content

No description has been added so far.

Project description

Build Status PyPI version License Test Coverage

Small python package that provides a @classproperty decorator for python classes that works just like @property except for class variables!

$ pip install classprop

Use it just like builtin @property’s:

from classprop import classprop

class TestClass:
    _internal = "Hello, World"

    @classprop
    def my_class_prop(self) -> str:
        return self._internal

    @my_class_prop.setter
    def my_class_prop(self, value: str) -> None:
        self._internal = value



foo = TestClass()
assert foo.my_class_prop == "Hello, World"

baz = TestClass()
assert baz.my_class_prop == "Hello, World"

baz.my_class_prop = "Changed"
assert foo.my_class_prop == "Changed"

Development

For detailed instructions see CONTRIBUTING.

Tests

You can run tests with

$ invoke test
$ invoke test --min-coverage=90     # Fail when code coverage is below 90%
$ invoke type-check                 # Run mypy type checks

Linting and formatting

Lint and format the code with

$ invoke format
$ invoke lint

All of this happens when you run invoke pre-commit.

Note

This project is still in the alpha stage and should not be considered production ready.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for classprop, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size classprop-0.1.1-py2.py3-none-any.whl (4.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size classprop-0.1.1.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page