arcane-typing
This package provides advanced typing patterns for Python projects that use ty.
Usage
Add arcane-typing as a dependency to your project:
uv add arcane-typing
Use one of its typing features in your code, for example:
from arcane_typing import has_attr_of_type
def get_name(obj: object) -> str:
if has_attr_of_type(obj, "name", str):
return obj.name.upper()
else:
return "<unknown>"
Use ty to type-check your code:
uv add --dev ty # If you are not already using it
uv run ty check
Features
Core functionality and types
Intersection[A, B]is an intersection type that represents values that are both of typeAand typeB.Not[T]describes values that are not of typeT.TypeOf[expr]can be used to obtain ty's inferred type for an expression in a type annotation or type alias.Top[T]can be used to refer to the top-materialization ofT.Bottom[T]can be used to refer to the bottom-materialization ofT.FunctionLikeCallable[P, R]works just likeCallable[P, R]but also allows attributes like__name__,__qualname__, or__code__to be accessed.NonEmptyStringexcludes the empty string literal fromstr.NonStringSequenceexcludes barestrfromSequence[str].try_import_module(name)returns the specific module type for a resolvable name, orNoneif it is not available.static_assert(condition[, msg])enforces a condition at type-check time.
TypedDict-related features
TypeOf[Keys[T]]gives a union of string literals for the keys that can appear in aTypedDictT.TypeOf[Values[T]]gives the union of value types that can appear in aTypedDictT.
Type-narrowing helpers
has_attr_of_type(obj, "name", T)narrowsobj.nameto typeTif the attribute exists and if it is an instance ofT(which can be a class or a union of classes)has_item_of_type(obj, "key", T)narrowsobj["key"]toTif the mapping contains the key and its value is an instance ofT.is_sequence_of(obj, T)checks thatobjis a sequence and that every element is an instance ofT(which can be a class or a union of classes). It narrowsobjtoSequence[T]on success.
Development
Use uv to run the following development tasks:
# Linting and formatting
uv run ruff check
uv run ruff format --check
# Type checking
TY_UV=scripts uv run ty check
# Markdown tests
uv run mdtest.py
Metadata
Release files for arcane-typing 0.2.0
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 |
|---|---|---|---|---|
| arcane_typing-0.2.0.tar.gz | 5.6 kB | Without provenance | Details for arcane_typing-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| arcane_typing-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for arcane_typing-0.2.0-py3-none-any.whl |
Total release size: 13.5 kB
Release files / arcane_typing-0.2.0.tar.gz
| Download URL | arcane_typing-0.2.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
187c970cc527ea68218506fbe513b3eafaa01ed0f554407bc3e5782c7ad1b755
|
|
BLAKE2b-256 checksum How to use checksums |
132f0894f2054018da82678968c1ec3dbdf6e9f018c36c1da295095541ea5e8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / arcane_typing-0.2.0-py3-none-any.whl
| Download URL | arcane_typing-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d35c5f9663ab4e66989f44cce50426ea3eaee8ed604913efa092cf252fb20e7
|
|
BLAKE2b-256 checksum How to use checksums |
da688cf650a9f104244ef808db4f23bf28a15aadc7fc67af9825b3b1b5f24259
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for arcane-typing 0.2.0
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.