Stefan Richthofer

Results 228 comments of Stefan Richthofer

Here is a first draft: ``` def get_subclasses(cls): orig = pytypes.type_util._find_base_with_origin(cls, object) res = cls.__subclasses__() if not orig is None and hasattr(orig, "__origin__") and not orig.__origin__ is None: candidates =...

By default, pytypes treats an unassigned typevar ``T`` as *unknown* in the sense that nothing is a subtype. (*unkown* is however subtype of ``Any``). By providing a writable dict for...

I noticed that with your corrected example, ``FullUnparam.__subclasses__()`` yields ``[FullUnparam2, FullUnparam[~T, int], HalfParam, FullUnparam[str, int], EntirelyParam, HalfParam[str]]``. Is that intended? Or should it be filtered somehow?

> We might wish to provide an option to make all of the variants appear This can be not just big, but infinite due to nesting. Also, remember that ``__subclasses__``...

Note that pytypes cannot include typing_inspect as dependency, because typing_inspect lacks support for various versions of ``typing`` and Python.

Already figured it out. Yes I would add that function. Could you provide updated tests? I.e. in the tests you posted above, how would the function deal with the keywords...

Sorry, I cannot reproduce ``is_subtype(Dict, Dict[str, int], bound_typevars={})`` returning an error. It returns ``False`` for me, as expected. Dict parameters are not covariant. > concerning the tests, I do not...

To get this finalized, I just wanted to add the method in its last version. In turned out that this approach seems to fail with typing-3.5.3.0 and earlier. Ideas?

It seems like behavior of ``__subclasses__()`` changes heavily between typing versions: ``FullUnparam.__subclasses__()`` (I removed ```` parameters from printout for better comparability): typing

It's somehow part of pytypes' goal to smoothen the rough edges between typing versions, to normalize uneven behavior. In that fashion, a normalizing solution would be the best I guess....