Skip to main content

A base class that prevents subclasses from being instantiated from an unqualified import.

Project description

fromless

Create objects that ban unqualified imports.

Example

In demo.py:

from fromless import MustBeQualified   # note the irony

class Qualified(MustBeQualified):
    def __init__(self):
        super().__init__()

And at your REPL:

>>> from demo import Qualified
>>> Qualified()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/chrisjrn/src/goodbye_to_from/src/test.py", line 5, in __init__
    super().__init__()
  File "/Users/chrisjrn/src/goodbye_to_from/src/fromless/gtf.py", line 12, in __init__
    MustBeQualified._error_if_unqualified(traceback)
  File "/Users/chrisjrn/src/goodbye_to_from/src/fromless/gtf.py", line 42, in _error_if_unqualified
    raise Exception(f"Class {enclosing_class} was instantiated from an alias.")
Exception: Class Qualified was instantiated from an alias.
>>> import demo
>>> demo.Qualified()
<demo.Qualified object at 0x101509dc0>

Perfect.

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

fromless-0.0.2.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

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

fromless-0.0.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file fromless-0.0.2.tar.gz.

File metadata

  • Download URL: fromless-0.0.2.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for fromless-0.0.2.tar.gz
Algorithm Hash digest
SHA256 0cc0ee80c2e23c40be5c514f6bd3ce67ad2d13e1f3101bf47ad7b9a0dba71eed
MD5 1d1b95eca4dc9dabe48705fcb2983b02
BLAKE2b-256 399f1ad393ee4fa6299b9ab98167b090dfb4b8b9c76424e9a9ef2b3b6867890f

See more details on using hashes here.

File details

Details for the file fromless-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: fromless-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for fromless-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6f0f116215e2d91ac8a760b2d7feada47058acda633baac58ed3279f612a0087
MD5 d81d43c3e6d593621c0f51c3eeddfe34
BLAKE2b-256 fd936859e440fcf8b7eca01b0a06e5762a712a6ffa19b2a77c5604f3e0475e04

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