Utilities for generic type inspection in Python.
Project description
generic-inspection
Utilities for generic type inspection. Supports Python 3.10+.
Inferring specialised type arguments
Consider the following code:
from typing import Generic, TypeVar
InputT = TypeVar("InputT")
OutputT = TypeVar("OutputT")
class Machine(Generic[InputT, OutputT]):
pass
class TextMachine(Machine[InputT, str]):
pass
class NumberTextMachine(TextMachine[float]):
pass
We can infer the specialised type arguments of a subclass
with respect to the class type parameters of a particular base class
using the infer_generic_args function.
>>> from generic_inspection import infer_generic_args
>>> infer_generic_args(Machine, NumberTextMachine)
(<class 'float'>, <class 'str'>)
The results here tell us that InputT is float and OutputT is str.
Development environment
# Set up the virtual environment.
uv sync --frozen --all-groups
# Run tests.
just test
Release process
The release process is automatic after pushing a semver tag to main.
# Ensure that the correct version number is in pyproject.toml.
head pyproject.toml
# Create the tag.
git tag -a v0.1.0 -m "Release v0.1.0"
# Push the tag.
git push --tags
# Check GitHub Actions and PyPI to verify successful publication.
Similar projects
License
Copyright 2026 Aiden Nibali
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
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 generic_inspection-0.1.0.tar.gz.
File metadata
- Download URL: generic_inspection-0.1.0.tar.gz
- Upload date:
- Size: 8.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 |
e807270771814a9b853d2a6ba6e2a317a0c0931daceb549c93bf72d16d8d7765
|
|
| MD5 |
7e7e09a085e19ab568cc91389dfce768
|
|
| BLAKE2b-256 |
718bccf5de66cbd78737bc7750288d663daaafd9b7d1045cb59a596fe58a2ac7
|
Provenance
The following attestation bundles were made for generic_inspection-0.1.0.tar.gz:
Publisher:
release.yaml on anibali/generic-inspection
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
generic_inspection-0.1.0.tar.gz -
Subject digest:
e807270771814a9b853d2a6ba6e2a317a0c0931daceb549c93bf72d16d8d7765 - Sigstore transparency entry: 910418853
- Sigstore integration time:
-
Permalink:
anibali/generic-inspection@fbcf74d27e8c02815f62c54f1bafb3fc2e1fd63f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/anibali
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@fbcf74d27e8c02815f62c54f1bafb3fc2e1fd63f -
Trigger Event:
push
-
Statement type:
File details
Details for the file generic_inspection-0.1.0-py3-none-any.whl.
File metadata
- Download URL: generic_inspection-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.5 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 |
37d2a734ae05ccd1e096de204005914b6ce4341b4921858aa814744e89de6eea
|
|
| MD5 |
9dc65e8e919f170dc93a579855e53962
|
|
| BLAKE2b-256 |
bd04474ef960a781f30aa52c006a4f5a773e92161b5eb40f79ed341f948f1f42
|
Provenance
The following attestation bundles were made for generic_inspection-0.1.0-py3-none-any.whl:
Publisher:
release.yaml on anibali/generic-inspection
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
generic_inspection-0.1.0-py3-none-any.whl -
Subject digest:
37d2a734ae05ccd1e096de204005914b6ce4341b4921858aa814744e89de6eea - Sigstore transparency entry: 910418858
- Sigstore integration time:
-
Permalink:
anibali/generic-inspection@fbcf74d27e8c02815f62c54f1bafb3fc2e1fd63f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/anibali
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@fbcf74d27e8c02815f62c54f1bafb3fc2e1fd63f -
Trigger Event:
push
-
Statement type: