Skip to main content

Comprehensive Object-Based Runtime Architecture

Project description

🐍 COBRA

Comprehensive Object-Based Runtime Architecture

COBRA is an experimental Python library that brings runtime encapsulation and object-oriented access control to Python using decorators, descriptors, and runtime inspection.

Unlike Python's naming conventions (_protected, __private), COBRA enforces access restrictions at runtime.


Features

✅ v0.2.0

  • Runtime enforced private methods
  • Descriptor-based private fields
  • Runtime access engine
  • Automatic class registration
  • Lightweight and dependency-free
  • Python 3.11+

Installation

pip install cobra-oop

Example

from cobra import CobraObject, PrivateField, private


class BankAccount(CobraObject):

    balance = PrivateField(default=1000)

    @private
    def calculate_interest(self):
        return self.balance * 0.08

    def interest(self):
        return self.calculate_interest()


account = BankAccount()

print(account.interest())

Output

80.0

Attempting to access private members directly:

account.calculate_interest()

raises

PrivateAccessError

Likewise,

account.balance

raises

PrivateAccessError

Current API

from cobra import (
    CobraObject,
    PrivateField,
    private,
)

Roadmap

✅ v0.1

  • Runtime private methods

✅ v0.2

  • Descriptor-based private fields
  • Runtime access engine
  • Runtime class registry

🚧 v0.3

  • Protected methods
  • Protected fields
  • Friend access
  • Runtime policy improvements

🚧 v0.4

  • Final methods
  • Final classes
  • Runtime validation

🎯 v1.0

  • Complete runtime encapsulation framework
  • Architecture enforcement
  • Static analysis integration
  • Framework integrations (Django, FastAPI)

Running Tests

python -m pytest

Contributing

Contributions, bug reports, feature requests, and design discussions are welcome.

Please open an issue before starting major changes.


License

MIT License


Author

Vishnu Swaroop

GitHub: https://github.com/vishnuswaroop21/cobra-oop

PyPI: https://pypi.org/project/cobra-oop/

Project details


Download files

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

Source Distribution

cobra_oop-0.2.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cobra_oop-0.2.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file cobra_oop-0.2.0.tar.gz.

File metadata

  • Download URL: cobra_oop-0.2.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for cobra_oop-0.2.0.tar.gz
Algorithm Hash digest
SHA256 45b803b6c550ba98c762584eed9f5a76c4df34993ec0f066c6959bbdaa6346c3
MD5 01003e470631f5bf6afbb89df7674306
BLAKE2b-256 c7882e181ffb76f14291e64de0c9001aa6d46b050ba008997e54e0eab1611da6

See more details on using hashes here.

File details

Details for the file cobra_oop-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cobra_oop-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for cobra_oop-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a01649e84634e2d3ebef9f93431f8ebebd0aa9b8ff88daa9442c725ff6cdd8a3
MD5 9a815f8a11446acea8e090b8b9660bea
BLAKE2b-256 494cc17b89db0e06d57af9a2bedf37d342686be5a41fb7e6025faaacb3ae3f20

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page