Is one None not enough for you? There's more
Project description
denial
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:
-
InnerNoneis not an instance ofNoneType, it has its own parent class. -
InnerNonecannot 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
Noneis considered equivalent totype(None).
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
Release history Release notifications | RSS feed
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2ec192316eabc1c7d74c9b383cffc15a4ff08383ebf0c564d340536907fcb9c
|
|
| MD5 |
1c9d39aeb25c0fd31b81d54f9b3a742d
|
|
| BLAKE2b-256 |
970a6cca99a7ce3fd94df6bf7637cce70d14e4b504941215d2392e6343bee13a
|
Provenance
The following attestation bundles were made for denial-0.0.1.tar.gz:
Publisher:
release.yml on pomponchik/denial
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
denial-0.0.1.tar.gz -
Subject digest:
a2ec192316eabc1c7d74c9b383cffc15a4ff08383ebf0c564d340536907fcb9c - Sigstore transparency entry: 831049049
- Sigstore integration time:
-
Permalink:
pomponchik/denial@2989112ba47da669c3bde62b631e653e4d6755df -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pomponchik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2989112ba47da669c3bde62b631e653e4d6755df -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27626d2b950d8bb83af43f9aed9c73a6b67ad1b9f616647f3aa9a950aeba1c3f
|
|
| MD5 |
c41eed178707d8d92e53343b3d8e6af3
|
|
| BLAKE2b-256 |
61fd56b55c1e33da2ce134bc4245ddbd3b403dcbc9c0e0ee1ae4a36afa07b64a
|
Provenance
The following attestation bundles were made for denial-0.0.1-py3-none-any.whl:
Publisher:
release.yml on pomponchik/denial
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
denial-0.0.1-py3-none-any.whl -
Subject digest:
27626d2b950d8bb83af43f9aed9c73a6b67ad1b9f616647f3aa9a950aeba1c3f - Sigstore transparency entry: 831049060
- Sigstore integration time:
-
Permalink:
pomponchik/denial@2989112ba47da669c3bde62b631e653e4d6755df -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pomponchik
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2989112ba47da669c3bde62b631e653e4d6755df -
Trigger Event:
push
-
Statement type: