Comments (6)
But this would be a simple combination of get_args
and get_origin
. I think we should get better API for more general functions rather than focus on many specialized functions.
from typing_inspect.
Yet again there is something in pytypes I'd like to point out.
pytypes.get_iterable_itemtype might be of some help, not the entire solution to this request though.
from typing_inspect.
Thanks ! yes @ilevkivskyi you are right, but that might be a "frequent" specialized request. See the collections
module: it is extremely useful, although specialized on collections. @Stewori I'll have a look
from typing_inspect.
@smarie it just occurred to me that pytypes.get_iterable_itemtype is only about iterable
from collections, not about Iterable
from typing
. Regarding a generic subtype of Iterable
from typing, pytypes also has a good (?) way to retrieve the item type, but that's not conveniently accessible via API right now IIRC. (We can maybe add such an API, it wouldn't be too hard using the already existing utilities. The question is more how such an API should exactly look like...)
from typing_inspect.
There are now functions in pytypes to accomplish this:
- pytypes.get_Generic_itemtype
- pytypes.get_Mapping_key_value
- pytypes.get_Generic_parameters
While the purpose of the first two is hopefully obvious, the third retrieves the parameters of a generic, viewed as a specific superclass.
I suppose this essentially solves this issue, once the next pytypes version is released.
from typing_inspect.
OK, I think we can close this for now, since pytypes
provide the functionality.
from typing_inspect.
Related Issues (20)
- is_literal broken with new typing_extensions HOT 3
- get_origin gives inconsistent results for differently defined Unions HOT 3
- `is_generic_type(List)` is False in 3.9 HOT 6
- Add Final type
- get_origin(Dict) returns None in python 3.9 HOT 1
- Support Python 3.9 HOT 4
- Add a simple is_type(t) method HOT 2
- 0.6.0: test suite is failing HOT 3
- Python 3.9 support breaks List HOT 2
- ImportError on typing_extensions HOT 1
- Fix for Python 3.9.0/1 does not work with typing_extensions 3.7.4. HOT 1
- `typing_inspect.get_args` `Annotated` metadata args HOT 1
- test_typed_dict_typing_extension fails with typing_extensions==4.1.1 HOT 3
- New release? HOT 2
- `get_origin()` doesn't support PEP 585 generic types? HOT 2
- Breaks `marshmallow_dataclass.NewType` HOT 4
- `get_parameters` throws exception with non-indexed types from `typing` on python 3.10 HOT 1
- `typed_dict_keys` fails to return data on 3.10 HOT 1
- BUG: is_union_type return None sometime HOT 2
- `get_parameters` failed for Tuple HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typing_inspect.