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.2.tar.gz (4.3 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.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: denial-0.0.2.tar.gz
  • Upload date:
  • Size: 4.3 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.2.tar.gz
Algorithm Hash digest
SHA256 8c8c9901a8c076cb65a8edfd7c2f90ca30bcf8f210c16426d7a8019ee5aa8241
MD5 4b05ce162d0e030fcc3d9e400fd9a1de
BLAKE2b-256 c7ce2a883bdd4cc81d984a566d0eaf85f7b8cafc0dd0252811e2af0a3cce6d5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for denial-0.0.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: denial-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a1bdee5bcadc86da333a71d99a6c7304406fade2b44ea3033a62921c73cc698a
MD5 8ef944e89c27b54a66826db51990b8f4
BLAKE2b-256 abda4159b77cac27a1e876c05ea1e6cd8fcd2c0158212b04fe6a84f45ba6f169

See more details on using hashes here.

Provenance

The following attestation bundles were made for denial-0.0.2-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