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.
Metadata
Release files for generic-inspection 0.1.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 | |
|---|---|---|---|
| generic_inspection-0.1.0.tar.gz | 8.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| generic_inspection-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.7 kB
Release files / generic_inspection-0.1.0.tar.gz
| Download URL | generic_inspection-0.1.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e807270771814a9b853d2a6ba6e2a317a0c0931daceb549c93bf72d16d8d7765
|
|
BLAKE2b-256 checksum How to use checksums |
718bccf5de66cbd78737bc7750288d663daaafd9b7d1045cb59a596fe58a2ac7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 4, 2026.
Transparency logRelease files / generic_inspection-0.1.0-py3-none-any.whl
| Download URL | generic_inspection-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37d2a734ae05ccd1e096de204005914b6ce4341b4921858aa814744e89de6eea
|
|
BLAKE2b-256 checksum How to use checksums |
bd04474ef960a781f30aa52c006a4f5a773e92161b5eb40f79ed341f948f1f42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 4, 2026.
Transparency log