Safe Typing is a module that provides a safe way to access types within the typing namespace.
It attempts to import types from the standard typing module first, and if not found,
it falls back to the typing_extensions module.
If a type is not found in either module, it returns a sentinel value NotFound.
Stop writing this:
import sys
if sys.version_info >= (3, 8):
from typing import List, Dict, Tuple
else:
from typing_extensions import List, Dict, Tuple
Use this instead:
from typing import List as TypingList, Dict as TypingDict
from safe_typing import _no_raise, List, Dict, FooBar, NotFound
# if you import _no_raise sentinel
# it will not raise an error when a name is not found in the module
# it will return a NotFound sentinel.
# otherwise, it will raise an ImportError
# if the name is not found in both typing and typing_extensions.
assert List is TypingList # True
assert Dict is TypingDict # True
assert FooBar is NotFound # FooBar does not exist in either typing or typing_extensions
You can reach me from contact@tomris.dev for collaborations, bug reports or feature requests.
Metadata
Release files for safe-typing 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| safe_typing-0.2.3.tar.gz | 2.4 kB | Without provenance | Details for safe_typing-0.2.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| safe_typing-0.2.3-py3-none-any.whl | Python 3 | none | any | Details for safe_typing-0.2.3-py3-none-any.whl |
Total release size: 5.3 kB
Release files / safe_typing-0.2.3.tar.gz
| Download URL | safe_typing-0.2.3.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3900fcd4d6df3c002f790de80103b6c6e65219a81b29350401ffbd518cc7f9c7
|
|
BLAKE2b-256 checksum How to use checksums |
ef356bd2c76cd067befc9cbd70e621e2c1dcdababad36f98618ed403b17971e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Release files / safe_typing-0.2.3-py3-none-any.whl
| Download URL | safe_typing-0.2.3-py3-none-any.whl |
|---|---|
| Size | 2.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e418d81c35fc116c1c27e50ed2b20297d264f6a14f0679a64cc729072700742
|
|
BLAKE2b-256 checksum How to use checksums |
5054236f7f0ed95368a3ea9964d83aa9abfcf7dd21dc0cda23be97374684ada0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Security for safe-typing 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.