Skip to main content

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.

  1. Use PascalCase (like PEP8 for classes), with a modificiation to append __ after every name of classes that inherit from Scope:
    class ExampleScope__(Scope): # Easy to know at a glance that given identifier is of type `type[Scope]`
    	example_field = 42
    
  2. Manually mark all methods as either @staticmethod or @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

nya_scope-0.3.1.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

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

nya_scope-0.3.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

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

Hashes for nya_scope-0.3.1.tar.gz
Algorithm Hash digest
SHA256 ac6b9425cf113382b1e67d52ba157095f21a59a4b2672ff45ae318a84be66f9c
MD5 03319c5f2ae55667956e482128e2c859
BLAKE2b-256 4f73c21b91da0d458e5c68b7b73515e7351c16b8b152d8e937bea78c74572ca6

See more details on using hashes here.

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

Hashes for nya_scope-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8d9ca19cb923e5e07412ff68136b3d9f91a8a5d8083f3e50bbf6d16df459b329
MD5 88cbeee5d34ba78ae8d1f2549bbd269a
BLAKE2b-256 a63f342def8f5cb93d9127ea61bdd83e7046fca98bc959dcad28d9d5d26a43d6

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