Small helper library for creating named scopes/inline modules
Project description
nya-scope (import name: nya_scope)
A small, but opinionated helper library for creating named scopes/inline modules Classes marked explicitly as scopes prevent their own intialization with a runtime error
Style Guide (optional)
You are free to adopt it in full, part, or not for your for your project, this is just what I found the most convenient for my projects for visual clarity & separation from other (regular) classes.
- Use
PascalCase(like PEP8 for classes), with a modificiation to append__after every name of classes that inherit fromScope:class ExampleScope__(Scope): # Easy to know at a glance that given identifier is of type `type[Scope]` example_field = 42
- Manually mark all methods as either
@staticmethodor@classmethod:class Outer__(Scope): class Inner__(Scope): value = 42 @classmethod # while there could've been also a mechanism to append those `@classmethod`s or `@staticmethod`s automatically at runtime, this was deemed infeasible due to 1. conflicts with other decorators (namely: order matters), 2. typing; therefore for now until a new solution is found, either @classmethod or @staticmethod is required to be specified manually, unless you don't care about typing. def class_method(here): # noqa: N804 <-- if using ruff, or disable this rule for projects using this package entirely if preferred # name your `cls`, `here` instead, it makes sense in this context print(here.value) @staticmethod def static_method(): print(Outer__.Inner__.value) # Inner__.value does not work
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nya_scope-0.3.1.tar.gz.
File metadata
- Download URL: nya_scope-0.3.1.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac6b9425cf113382b1e67d52ba157095f21a59a4b2672ff45ae318a84be66f9c
|
|
| MD5 |
03319c5f2ae55667956e482128e2c859
|
|
| BLAKE2b-256 |
4f73c21b91da0d458e5c68b7b73515e7351c16b8b152d8e937bea78c74572ca6
|
File details
Details for the file nya_scope-0.3.1-py3-none-any.whl.
File metadata
- Download URL: nya_scope-0.3.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d9ca19cb923e5e07412ff68136b3d9f91a8a5d8083f3e50bbf6d16df459b329
|
|
| MD5 |
88cbeee5d34ba78ae8d1f2549bbd269a
|
|
| BLAKE2b-256 |
a63f342def8f5cb93d9127ea61bdd83e7046fca98bc959dcad28d9d5d26a43d6
|