Convert a class with generic type parameters to be generic at runtime.
Project description
1-line decorator to allow a class to be subclassed via generic syntax.
Specifically limited to the pattern where:
- a class variable is declared, unbound, as type[T], where T is a generic class parameter.
- An arbitary amount of such type parameters can be handled.
Example
from brewinglib.generic import runtime_generic
@runtime_generic
class SomeGenericClass[A, B]:
attr_a: type[A]
attr_b: type[B]
class ThingA:
thinga = "foo"
class ThingB:
thingb = "bar"
assert SomeGenericClass[ThingA, ThingB]().attr_a.thinga == "foo"
assert SomeGenericClass[ThingA, ThingB]().attr_b.thingb == "bar"
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 brewinglib_generic-0.0.6.tar.gz.
File metadata
- Download URL: brewinglib_generic-0.0.6.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cd079aac46beef67c41becef601298018d926416f8fc5697038638ad5db9598
|
|
| MD5 |
0e440605b79ad857dcfd03037e7ced3b
|
|
| BLAKE2b-256 |
bbae7278dbad447123be75249e54cf0affadf06ff0a096344c64c267121c881b
|
File details
Details for the file brewinglib_generic-0.0.6-py3-none-any.whl.
File metadata
- Download URL: brewinglib_generic-0.0.6-py3-none-any.whl
- Upload date:
- Size: 2.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83e55b1c83260e5fc996e645fdfc37fb86d4a1d9cef0c830c6f670af48f5301f
|
|
| MD5 |
96baff340d466ae89622007bbd8adee4
|
|
| BLAKE2b-256 |
77dd217537fde8aab44497467d59836b8bf65626c6d362486620ee5e71a94d17
|