Skip to main content

Is one None not enough for you? There's more

Project description

denial

Downloads Downloads Coverage Status Lines of code Hits-of-Code Test-Package Python versions PyPI version Checked with mypy Ruff DeepWiki

There is a small but annoying misunderstanding in the design of Python as a language. The language defines the constant None, which designates a special object that is used as a "stub" when it is not possible to use the "real" value. But sometimes, when implementing libraries, it is not possible to distinguish None, passed by the user as the default value, from None, which means that the value is really undefined. In some rare cases, this distinction is important.

For example, the dataclasses library defines a special MISSING constant for such cases. This is used to separate the cases when the user has not set a default value from the case when he has set None as the default value. However, the use of MISSING is tied to the use of this library, and sometimes this constant may be needed for completely different purposes.

This library defines just such an object: None for situations where you need to distinguish None as a value from the user, and None as a designation that something is really undefined. This value should not fall "outside", into the user's space, it should remain only inside the libraries implementations.

Well, how to use it?

Let's start with the installation:

pip install denial

This is how this additional version of None and its class are imported (can be used for type hints or checks via isinstance):

from denial import InnerNone, InnerNoneType

InnerNone is used the same way as None, with a couple of additional caveats:

  1. InnerNone is not an instance of NoneType, it has its own parent class.

  2. InnerNone cannot be used as your own type hint. What am I talking about? Let's look at the documentation:

When used in a type hint, the expression None is considered equivalent to type(None).

Official typing documentation

In most type checkers, this is implemented using a special "crutch", an exception in the code that cannot be repeated for any other value. Therefore, use InnerNoneType as a type hint.

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

denial-0.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

denial-0.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file denial-0.0.1.tar.gz.

File metadata

  • Download URL: denial-0.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for denial-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a2ec192316eabc1c7d74c9b383cffc15a4ff08383ebf0c564d340536907fcb9c
MD5 1c9d39aeb25c0fd31b81d54f9b3a742d
BLAKE2b-256 970a6cca99a7ce3fd94df6bf7637cce70d14e4b504941215d2392e6343bee13a

See more details on using hashes here.

Provenance

The following attestation bundles were made for denial-0.0.1.tar.gz:

Publisher: release.yml on pomponchik/denial

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file denial-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: denial-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for denial-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 27626d2b950d8bb83af43f9aed9c73a6b67ad1b9f616647f3aa9a950aeba1c3f
MD5 c41eed178707d8d92e53343b3d8e6af3
BLAKE2b-256 61fd56b55c1e33da2ce134bc4245ddbd3b403dcbc9c0e0ee1ae4a36afa07b64a

See more details on using hashes here.

Provenance

The following attestation bundles were made for denial-0.0.1-py3-none-any.whl:

Publisher: release.yml on pomponchik/denial

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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