Skip to main content

safe-typing is a module that provides a safe way to access types within the typing/typing_extensions namespaces.

Reason this release was yanked:

Has misused sentinel

Project description

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.

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

safe_typing-0.2.2.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

safe_typing-0.2.2-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file safe_typing-0.2.2.tar.gz.

File metadata

  • Download URL: safe_typing-0.2.2.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for safe_typing-0.2.2.tar.gz
Algorithm Hash digest
SHA256 98e5126fa23385cedacfdc55045feb0e991e364dd9a4eb91cb59220cb8883bd1
MD5 b63c9057edfcc5deaad6b19a827e7c1a
BLAKE2b-256 310986705c22e37c68b5db1adde3c1789eb68f3b04cd7f26e76660cd1a195611

See more details on using hashes here.

File details

Details for the file safe_typing-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: safe_typing-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for safe_typing-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8aa432c9e4a28cb2ddba481939b53be8a11bf7a240e496bc490a335d00b354b2
MD5 bd45b694a46e6073e1b7517d597bfbe4
BLAKE2b-256 2f4e77717e671df1d0fc8e3219f2c9d6638db6dc5739ad789108f1f00619fdf4

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