Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpret type annotations as type[Any] annotations #16366

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

tyralla
Copy link
Contributor

@tyralla tyralla commented Oct 29, 2023

Fixes #16349

I had to adjust three existing tests. In my opinion, all necessary adjustments indicate an increase in consistency.

@github-actions

This comment has been minimized.

@tyralla
Copy link
Contributor Author

tyralla commented Oct 29, 2023

Regarding the Mypy primer's output, most changes inform about missing type arguments for type (as expected). I will check the other changes later.

All the failing Mypyc test suits also seem to be due to missing type arguments. No idea how many such problems exist. I am not familiar with Mypyc, but I suppose that inserting the most precise type possible leads to higher efficiency than just inserting Any?

This comment has been minimized.

@tyralla
Copy link
Contributor Author

tyralla commented Nov 13, 2023

All the failing Mypyc test suits also seem to be due to missing type arguments. No idea how many such problems exist. I am not familiar with Mypyc, but I suppose that inserting the most precise type possible leads to higher efficiency than just inserting Any?

Now, the Mypyc tests also pass. I just had to add exactly one annotation...

Also, I switched from type[Any} to type[object] annotations, which seems to work in all cases.

@tyralla
Copy link
Contributor Author

tyralla commented Nov 14, 2023

I had a look at the Mypy primer diff. Most differences are, as expected, complaints about missing type arguments and error messages that now contain type[Any] instead of type, so that's okay. The other differences are mainly due to Mypy now understanding that object is no subtype of type, which also looks like a relevant improvement.

So, I think this pull request is ready for review.

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an improvement but unfortunately I think it's not quite right yet. The trouble is that type sometimes should be interpreted as type[Any] even if it's not syntactically within an annotation.

For example, consider this:

from typing import Type
class L1(list[type]): ...
class L2(list[Type]): ...

l1: L1
for elt in l1:
    reveal_type(elt)
l2: L2
for elt in l2:
    reveal_type(elt)

With your PR, when I put this in a test case I get

  main:36: note: Revealed type is "builtins.type" (diff)
  main:39: note: Revealed type is "Type[Any]" (diff)

While I would expect both to behave the same way.

I haven't tried it but I suspect you'll see similar issues in other places where types can appear outside annotations (e.g., cast(), TypeVar bounds).

Intuitively, I think the right behavior is that analyze_annotation should always be true. However, when I tried that, I got a ton of test failures about inheriting from type. Maybe there's a way to fix that, though.

@tyralla
Copy link
Contributor Author

tyralla commented Nov 14, 2023

You are right; addressing all places where type can be typed would be a bigger improvement. I will give it a try...

@tyralla
Copy link
Contributor Author

tyralla commented Nov 15, 2023

After some thinking and reading, I think analyze_annotation should be more often but not always true. It should be only true if type could be replaced with Type (for now). In my understanding, type (unfortunately) currently has three different meanings:

First, it allows us to define that we want to handle the class of an instance and not the instance itself. That is what this pull request is about, and I clearly should support Jelle's example, cast, and so on.

Second, it serves as a function to query the type of an object. In this regard, type(instance) is somehow like type[object](instance) and also like type[Any](instance) because it accepts instances of any type, and every type is a subtype of object. But forcing users to write type[object](instance) seems weird. (Then, what would type[int](instance) mean? That instance must be a subtype of int, and type checkers should otherwise throw an error?) So here, I guess analyze_annotation should be false for now.

Third, it serves as a factory function for generating class objects. Here, anything I can think of is that T in type[T] could mean the return type. The following code works, but Mypy complains:

class A: x = 1
B = type("B", (A,), {})
print(B.x)  # error: "type" has no attribute "x"

So, here it could eventually be helpful to annotate with A, but then Mypy says:

class A: x = 1
B = type[A]("B", (A,), {})  # error: Value of type "type[type]" is not indexable

I am sure others have thought this through much more thoroughly, and this is way beyond my current intention. Hence, for this pull request, analyze_annotation should also be false in such cases for now, in my opinion.

This comment has been minimized.

@JelleZijlstra
Copy link
Member

Some quick notes (will have a full review later):

  • The jax hit in mypy-primer above is concerning, since it seems to indicate a bug where mypy thinks types are not hashable. That needs to be fixed.
  • I'm not convinced by your argument for why analyze_annotation shouldn't always be true, because in the contexts you outline, we shouldn't be calling anal_type in the first place (since these contexts do not hold types).
  • I don't like the name analyze_annotation, I think it should be something like is_annotation, or even is_type since we also use it outside of annotations.

@tyralla
Copy link
Contributor Author

tyralla commented Nov 16, 2023

Some quick notes (will have a full review later):

Thanks!

  • The jax hit in mypy-primer above is concerning, since it seems to indicate a bug where mypy thinks types are not hashable. That needs to be fixed.

Yes, and there are some more problems I have to think about, too. I will do it later.

  • I'm not convinced by your argument for why analyze_annotation shouldn't always be true, because in the contexts you outline, we shouldn't be calling anal_type in the first place (since these contexts do not hold types).

I misunderstood and thought you suggested to always convert type to type[Any]. I will rethink this.

  • I don't like the name analyze_annotation, I think it should be something like is_annotation, or even is_type since we also use it outside of annotations.

Okay, let's decide on the name as soon as everything works as desired.

…e it true by default to cover more cases

 * Add the `BUILTIN_TYPE_USED_AS_GENERIC` error message
 * Complete the "testBuiltinTypeType" test case
 * Adjust other test cases
 * Adjust two stub files
 * Replace additional `type` annotations with `type[object]` in Mypy's code
@tyralla
Copy link
Contributor Author

tyralla commented Nov 21, 2023

I added a commit, but the test machinery does not start.

Anyhow, I renamed analyze_annotation to builtin_type_is_type_type (long but relatively explicit, IMO) and made it true by default. There are only very few exceptions related to:

t = type
class A(metaclass=t)

class B(type): ...

This new behaviour is debatable (conflicts with dataclasses.pyi):

_InitVarMeta: TypeAlias = type  # E: Missing type parameters for generic type "type"
class InitVar(Generic[_T], metaclass=_InitVarMeta):  # E: Invalid metaclass "_InitVarMeta"

Also, I added a new error message that tries to clarify things:

type[str](1)  # E: "builtins.type" is indexable as a type hint but neither a generic class nor a generic function
r = type[str]("r", (), {})  # E: "builtins.type" is indexable as a type hint but neither a generic class nor a generic function
class S(type[str]): ...  # E: "builtins.type" is indexable as a type hint but neither a generic class nor a generic function

I would look after the hashability problem and check if the code changes could be further simplified after we agreed on (or modified) these functionalities.

This comment has been minimized.

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is looking like a step in the right direction.

test-data/unit/check-generics.test Show resolved Hide resolved
test-data/unit/check-newsemanal.test Outdated Show resolved Hide resolved
test-data/unit/check-newsemanal.test Outdated Show resolved Hide resolved
@@ -77,7 +87,7 @@ class bool(int): pass

class ellipsis:
__class__: object
def isinstance(x: object, t: Union[type, Tuple[type, ...]]) -> bool: pass
def isinstance(x: object, t: Union[type[Any], Tuple[type[Any], ...]]) -> bool: pass # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need a type ignore? I thought it might be that mypy didn't think type was indexable, but it seems fine in the tuple fixture below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add it because one test case (I cannot remember which one) uses dict.pyi in combination with the disallow-any-generics flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just saw that I also had to add a type: ignore to tuple.pyi for similar reasons. testDisallowAnyExplicitGenericAlias uses the disallow-any-explicit flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testErrorCodeMissingMultiple demands error codes in type ignores. I added them.

JelleZijlstra added a commit to JelleZijlstra/flake8-pyi that referenced this pull request Nov 21, 2023
@JelleZijlstra
Copy link
Member

This new behaviour is debatable (conflicts with dataclasses.pyi):

The new behavior feels right. The metaclass is a runtime concept; we don't need to allow using a type alias there.

@tyralla
Copy link
Contributor Author

tyralla commented Nov 21, 2023

This new behaviour is debatable (conflicts with dataclasses.pyi):

The new behavior feels right. The metaclass is a runtime concept; we don't need to allow using a type alias there.

Yes, I thought so, too. Okay, then I will leave it like this and will next have a look at the hashability problem.

This comment has been minimized.

This comment has been minimized.

mypy/subtypes.py Outdated
if (
right.type.is_protocol
and (len(right.type.protocol_members) == 1)
and (right.type.protocol_members[0] == "__hash__")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would behave incorrectly in an exotic case where the protocol contains a member named __hash__ that doesn't have the standard signature. Maybe that's OK though as it's better than the current state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same holds for the potential subclass. I added additional checks for both of them.

test-data/unit/check-newsemanal.test Show resolved Hide resolved

This comment has been minimized.

This comment has been minimized.

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good, but the amount of primer hits is concerning (cc @JukkaL). I think this is the right thing to do, but it's prudent to wait until the Typing Council decides on type/Type semantics (https://discuss.python.org/t/inconsistencies-between-type-and-type/37404/12), and we may need some mechanism to make migration easier, maybe an error code specifically for bare type.

mypy/subtypes.py Outdated
return True
if isinstance(item, Instance):
if (mtype := item.type.metaclass_type) is None or (
symtab := mtype.type.get("__hash__")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symtab looks unused here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it.

JelleZijlstra added a commit to JelleZijlstra/cpython that referenced this pull request Dec 10, 2023
Bare "type" in annotations should be equivalent to "type[Any]"; see
https://discuss.python.org/t/inconsistencies-between-type-and-type/37404
and python/mypy#16366. It's better to use "type[object]", which is
safer and unambiguous.
AlexWaygood pushed a commit to python/cpython that referenced this pull request Dec 10, 2023
Bare "type" in annotations should be equivalent to "type[Any]"; see
https://discuss.python.org/t/inconsistencies-between-type-and-type/37404
and python/mypy#16366. It's better to use "type[object]", which is
safer and unambiguous.

This comment has been minimized.

aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
Bare "type" in annotations should be equivalent to "type[Any]"; see
https://discuss.python.org/t/inconsistencies-between-type-and-type/37404
and python/mypy#16366. It's better to use "type[object]", which is
safer and unambiguous.
@tyralla
Copy link
Contributor Author

tyralla commented Apr 6, 2024

@JelleZijlstra @JukkaL It seems the Typing Council decided in agreement with this PR; at least the typing specs indicate so:

Plain type without brackets, the root of Python's metaclass hierarchy, is equivalent to type[Any].

So, a possible migration mechanism is the only issue left for this PR, isn't it? Personally, I think that adding the missing parameters (or just Any) should not be too much effort, even for large code bases. However, I could try to add a specific error code which allows silencing the Missing type parameters for generic type "type" errors and inserts Any automatically.

edo38 pushed a commit to edo38/python-clinic that referenced this pull request Apr 24, 2024
Bare "type" in annotations should be equivalent to "type[Any]"; see
https://discuss.python.org/t/inconsistencies-between-type-and-type/37404
and python/mypy#16366. It's better to use "type[object]", which is
safer and unambiguous.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
Bare "type" in annotations should be equivalent to "type[Any]"; see
https://discuss.python.org/t/inconsistencies-between-type-and-type/37404
and python/mypy#16366. It's better to use "type[object]", which is
safer and unambiguous.
Copy link
Contributor

github-actions bot commented Nov 3, 2024

Diff from mypy_primer, showing the effect of this PR on open source code:

python-htmlgen (https://github.com/srittau/python-htmlgen)
+ htmlgen/attribute.pyi:14: error: Missing type parameters for generic type "type"  [type-arg]
+ htmlgen/attribute.pyi:20: error: Missing type parameters for generic type "type"  [type-arg]
+ htmlgen/attribute.pyi:28: error: Missing type parameters for generic type "type"  [type-arg]
+ htmlgen/attribute.pyi:37: error: Missing type parameters for generic type "type"  [type-arg]
+ htmlgen/attribute.pyi:46: error: Missing type parameters for generic type "type"  [type-arg]
+ htmlgen/attribute.pyi:55: error: Missing type parameters for generic type "type"  [type-arg]
+ htmlgen/attribute.pyi:66: error: Missing type parameters for generic type "type"  [type-arg]
+ htmlgen/attribute.pyi:74: error: Missing type parameters for generic type "type"  [type-arg]

manticore (https://github.com/trailofbits/manticore)
+ manticore/wasm/types.py:56: error: Unused "type: ignore" comment  [unused-ignore]
+ manticore/wasm/executor.py:402: error: Unused "type: ignore" comment  [unused-ignore]
+ manticore/wasm/executor.py:1226: error: Unused "type: ignore" comment  [unused-ignore]

prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/utilities/collections.py:407: error: Redundant cast to "type[Any]"  [redundant-cast]
- src/prefect/utilities/pydantic.py:189: note:     def __new__(type[type], object, /) -> type
+ src/prefect/utilities/pydantic.py:189: note:     def __new__(type[type], object, /) -> type[Any]
- src/prefect/utilities/pydantic.py:189: note:     def [_typeshed.Self] __new__(type[_typeshed.Self], str, tuple[type, ...], dict[str, Any], /, **kwds: Any) -> _typeshed.Self
+ src/prefect/utilities/pydantic.py:189: note:     def [_typeshed.Self] __new__(type[_typeshed.Self], str, tuple[type[Any], ...], dict[str, Any], /, **kwds: Any) -> _typeshed.Self
- src/prefect/utilities/pydantic.py:191: note:     def __new__(type[type], object, /) -> type
+ src/prefect/utilities/pydantic.py:191: note:     def __new__(type[type], object, /) -> type[Any]
- src/prefect/utilities/pydantic.py:191: note:     def [_typeshed.Self] __new__(type[_typeshed.Self], str, tuple[type, ...], dict[str, Any], /, **kwds: Any) -> _typeshed.Self
+ src/prefect/utilities/pydantic.py:191: note:     def [_typeshed.Self] __new__(type[_typeshed.Self], str, tuple[type[Any], ...], dict[str, Any], /, **kwds: Any) -> _typeshed.Self
- src/prefect/settings/legacy.py:105: error: Argument 1 to "__call__" of "_lru_cache_wrapper" has incompatible type "type[PrefectBaseSettings]"; expected "Hashable"  [arg-type]
- src/prefect/settings/legacy.py:105: note: Following member(s) of "PrefectBaseSettings" have conflicts:
- src/prefect/settings/legacy.py:105: note:     Expected:
- src/prefect/settings/legacy.py:105: note:         def __hash__() -> int
- src/prefect/settings/legacy.py:105: note:     Got:
- src/prefect/settings/legacy.py:105: note:         def __hash__(self: object) -> int
- src/prefect/settings/legacy.py:105: note:     Expected:
- src/prefect/settings/legacy.py:105: note:         def __hash__() -> int
- src/prefect/settings/legacy.py:105: note:     Got:
- src/prefect/settings/legacy.py:105: note:         def __hash__(self: object) -> int
- src/prefect/settings/legacy.py:136: error: Argument 1 to "__call__" of "_lru_cache_wrapper" has incompatible type "type[PrefectBaseSettings]"; expected "Hashable"  [arg-type]
- src/prefect/settings/legacy.py:136: note: Following member(s) of "PrefectBaseSettings" have conflicts:
- src/prefect/settings/legacy.py:136: note:     Expected:
- src/prefect/settings/legacy.py:136: note:         def __hash__() -> int
- src/prefect/settings/legacy.py:136: note:     Got:
- src/prefect/settings/legacy.py:136: note:         def __hash__(self: object) -> int
- src/prefect/settings/legacy.py:136: note:     Expected:
- src/prefect/settings/legacy.py:136: note:         def __hash__() -> int
- src/prefect/settings/legacy.py:136: note:     Got:
- src/prefect/settings/legacy.py:136: note:         def __hash__(self: object) -> int
- src/prefect/blocks/core.py:244: error: "type" has no attribute "_to_block_schema_reference_dict"  [attr-defined]
- src/prefect/blocks/core.py:248: error: "type" has no attribute "_to_block_schema_reference_dict"  [attr-defined]
- src/prefect/blocks/core.py:251: error: "type" has no attribute "_to_block_schema_reference_dict"  [attr-defined]
- src/prefect/blocks/core.py:1081: error: "type" has no attribute "register_type_and_schema"  [attr-defined]

pydantic (https://github.com/pydantic/pydantic)
- pydantic/config.py:1052: error: "_TypeT" has no attribute "__pydantic_config__"  [attr-defined]
- pydantic/_internal/_core_utils.py:90: error: "object" has no attribute "__name__"; maybe "__ne__" or "__new__"?  [attr-defined]
- pydantic/_internal/_generate_schema.py:130: error: List item 1 has incompatible type "<typing special form>"; expected "type"  [list-item]
+ pydantic/_internal/_generate_schema.py:130: error: List item 1 has incompatible type "<typing special form>"; expected "type[Any]"  [list-item]
- pydantic/_internal/_generate_schema.py:944: error: Argument 1 to "_type_alias_type_schema" of "GenerateSchema" has incompatible type "object"; expected "TypeAliasType"  [arg-type]
- pydantic/_internal/_generate_schema.py:1620: error: "object" has no attribute "__value__"  [attr-defined]
+ pydantic/_internal/_model_construction.py:296: error: Unused "type: ignore" comment  [unused-ignore]

Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/_internal/vendor/inspect.pyi:248: error: Missing type parameters for generic type "type"  [type-arg]
+ tanjun/_internal/vendor/inspect.pyi:249: error: Missing type parameters for generic type "type"  [type-arg]
+ tanjun/_internal/vendor/inspect.pyi:289: error: Missing type parameters for generic type "type"  [type-arg]
+ tanjun/_internal/vendor/inspect.pyi:365: error: Missing type parameters for generic type "type"  [type-arg]
+ tanjun/_internal/vendor/inspect.pyi:368: error: Missing type parameters for generic type "type"  [type-arg]

psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/abc.py:25: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/abc.py:34: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/abc.py:113: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/_typeinfo.py:28: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/_adapters_map.py:64: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/_adapters_map.py:69: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/_adapters_map.py:112: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/_adapters_map.py:189: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/adapt.py:38: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/adapt.py:143: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/string.py:23: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/string.py:133: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/range.py:289: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/numeric.py:150: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/numeric.py:373: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/numeric.py:375: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/net.py:95: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/json.py:143: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/json.py:225: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/enum.py:111: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/datetime.py:196: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/composite.py:53: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/composite.py:134: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/array.py:41: error: Missing type parameters for generic type "type"  [type-arg]
+ psycopg/psycopg/types/array.py:292: error: Unused "type: ignore" comment  [unused-ignore]
+ psycopg/psycopg/types/multirange.py:185: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/fix_gc.py:22: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/fix_faker.py:47: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/fix_faker.py:68: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/fix_faker.py:71: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/fix_faker.py:79: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/fix_faker.py:202: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/fix_faker.py:228: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/fix_faker.py:252: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/adapters_example.py:20: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/adapters_example.py:31: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/test_copy_async.py:340: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/test_copy.py:329: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/types/test_numeric.py:81: error: Missing type parameters for generic type "type"  [type-arg]

jinja (https://github.com/pallets/jinja)
+ src/jinja2/environment.py:1189: error: Unused "type: ignore" comment  [unused-ignore]
+ src/jinja2/environment.py:1204: error: Unused "type: ignore" comment  [unused-ignore]

cwltool (https://github.com/common-workflow-language/cwltool)
+ cwltool/cwlprov/provenance_profile.py:13: note: In module imported here:
+ mypy-stubs/prov/model.pyi: note: In member "get_records" of class "ProvBundle":
+ mypy-stubs/prov/model.pyi:226:13: error: Missing type parameters for generic type "type"  [type-arg]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/dtypes/cast.py:591: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/core/arrays/datetimelike.py:610: error: Unused "type: ignore" comment  [unused-ignore]
+ pandas/core/reshape/merge.py:2846: error: Unused "type: ignore" comment  [unused-ignore]

more-itertools (https://github.com/more-itertools/more-itertools)
+ more_itertools/more.pyi:45: error: Missing type parameters for generic type "type"  [type-arg]

artigraph (https://github.com/artigraph/artigraph)
+ stubs/parse.pyi:7: error: Missing type parameters for generic type "type"  [type-arg]
+ src/arti/internal/type_hints.py:23: error: Missing type parameters for generic type "type"  [type-arg]
+ src/arti/internal/type_hints.py:38: error: Missing type parameters for generic type "type"  [type-arg]
+ src/arti/internal/type_hints.py:44: error: Missing type parameters for generic type "type"  [type-arg]
+ src/arti/internal/type_hints.py:51: error: Missing type parameters for generic type "type"  [type-arg]
- src/arti/internal/type_hints.py:54: error: Non-overlapping identity check (left operand type: "type", right operand type: "<typing special form>")  [comparison-overlap]
+ src/arti/internal/type_hints.py:54: error: Non-overlapping identity check (left operand type: "type[Any]", right operand type: "<typing special form>")  [comparison-overlap]
- src/arti/internal/type_hints.py:55: error: Non-overlapping identity check (left operand type: "type", right operand type: "<typing special form>")  [comparison-overlap]
+ src/arti/internal/type_hints.py:55: error: Non-overlapping identity check (left operand type: "type[Any]", right operand type: "<typing special form>")  [comparison-overlap]
+ src/arti/internal/type_hints.py:93: error: Missing type parameters for generic type "type"  [type-arg]
- src/arti/internal/type_hints.py:104: error: Returning Any from function declared to return "tuple[type, ...]"  [no-any-return]
+ src/arti/internal/type_hints.py:104: error: Returning Any from function declared to return "tuple[type[Any], ...]"  [no-any-return]
+ src/arti/internal/type_hints.py:105: error: Unused "type: ignore" comment  [unused-ignore]
+ src/arti/internal/type_hints.py:166: error: Missing type parameters for generic type "type"  [type-arg]
+ src/arti/internal/dispatch.py:60: error: Missing type parameters for generic type "type"  [type-arg]
+ src/arti/versions/__init__.py:68: error: Missing type parameters for generic type "type"  [type-arg]
+ src/arti/views/__init__.py:27: error: Missing type parameters for generic type "type"  [type-arg]
+ src/arti/views/__init__.py:30: error: Missing type parameters for generic type "type"  [type-arg]
+ src/arti/producers/__init__.py:232: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/arti/views/test_views.py:14: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/arti/internal/test_type_hints.py:79: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/arti/internal/test_type_hints.py:132: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/arti/internal/test_type_hints.py:164: error: Missing type parameters for generic type "type"  [type-arg]

pywin32 (https://github.com/mhammond/pywin32)
+ win32/Lib/win32timezone.py:261:31: error: Missing type parameters for generic type "type"  [type-arg]

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/ext/autodoc/mock.py: note: In member "__mro_entries__" of class "_MockObject":
+ sphinx/ext/autodoc/mock.py:55:64: error: Missing type parameters for generic type "type"  [type-arg]
+ sphinx/domains/std/__init__.py: note: In function "get_enumerable_node_type":
+ sphinx/domains/std/__init__.py:1133:43: error: Missing type parameters for generic type "type"  [type-arg]

bokeh (https://github.com/bokeh/bokeh)
+ src/bokeh/util/serialization.py: note: In function "_compute_datetime_types":
+ src/bokeh/util/serialization.py:54:38: error: Missing type parameters for generic type "type"  [type-arg]

streamlit (https://github.com/streamlit/streamlit)
+ lib/streamlit/type_util.py: note: In function "get_fqn":
+ lib/streamlit/type_util.py:120:23: error: Missing type parameters for generic type "type"  [type-arg]
+ lib/streamlit/type_util.py: note: At top level:
+ lib/streamlit/type_util.py:130:32: error: Missing type parameters for generic type "type"  [type-arg]
+ lib/streamlit/config_option.py: note: In member "__init__" of class "ConfigOption":
+ lib/streamlit/config_option.py:109:16: error: Missing type parameters for generic type "type"  [type-arg]
+ lib/streamlit/config.py: note: In function "_create_option":
+ lib/streamlit/config.py:212:12: error: Missing type parameters for generic type "type"  [type-arg]
+ lib/streamlit/elements/write.py: note: In member "write" of class "WriteMixin":
+ lib/streamlit/elements/write.py:497:30: error: Redundant cast to "Type[Any]"  [redundant-cast]
+ lib/streamlit/elements/write.py:497:35: error: Missing type parameters for generic type "type"  [type-arg]
+ lib/streamlit/delta_generator.py: note: In member "_block" of class "DeltaGenerator":
+ lib/streamlit/delta_generator.py:505:18: error: Missing type parameters for generic type "type"  [type-arg]
+ lib/tests/streamlit/data_test_cases.py:79:20: error: Missing type parameters for generic type "type"  [type-arg]
+ lib/tests/streamlit/data_test_cases.py: note: In class "CaseMetadata":
+ lib/tests/streamlit/data_test_cases.py:79:20: error: Missing type parameters for generic type "type"  [type-arg]
+ lib/tests/streamlit/data_test_cases.py: note: At top level:

mypy (https://github.com/python/mypy)
+ mypy/nodes.py:3512: error: Missing type parameters for generic type "type"  [type-arg]
+ mypy/nodes.py:3512: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-type-arg for more info
+ mypy/fastparse.py:387: error: Missing type parameters for generic type "type"  [type-arg]
+ mypy/stubutil.py:314: error: Missing type parameters for generic type "type"  [type-arg]
+ mypy/stubgenc.py:761: error: Missing type parameters for generic type "type"  [type-arg]
+ mypy/stubgenc.py:772: error: Missing type parameters for generic type "type"  [type-arg]
+ mypy/stubgenc.py:784: error: Missing type parameters for generic type "type"  [type-arg]
+ mypy/stubgenc.py:791: error: Missing type parameters for generic type "type"  [type-arg]
+ mypy/messages.py:2116: error: Missing type parameters for generic type "type"  [type-arg]
+ mypy/test/helpers.py:316: error: Missing type parameters for generic type "type"  [type-arg]
+ mypy/test/helpers.py:323: error: Missing type parameters for generic type "type"  [type-arg]

xarray (https://github.com/pydata/xarray)
+ xarray/namedarray/_typing.py: note: In member "__array_function__" of class "_arrayfunction":
+ xarray/namedarray/_typing.py:182: error: Missing type parameters for generic type "type"  [type-arg]

spark (https://github.com/apache/spark)
+ python/pyspark/sql/worker/analyze_udtf.py:132: error: Unused "type: ignore" comment  [unused-ignore]
+ python/pyspark/sql/worker/analyze_udtf.py:147: error: Unused "type: ignore" comment  [unused-ignore]

beartype (https://github.com/beartype/beartype)
+ beartype/_util/api/external/utilnumpy.py:176: error: Unused "type: ignore" comment  [unused-ignore]
+ beartype/_check/forward/reference/fwdrefabc.py:220: error: Argument "type_bases" to "_make_forwardref_subtype" has incompatible type "tuple[Callable[[VarArg(Any), KwArg(Any)], Never]]"; expected "tuple[type[Any], ...]"  [arg-type]
+ beartype/_check/forward/reference/fwdrefmake.py:94: error: Argument "type_bases" to "_make_forwardref_subtype" has incompatible type "tuple[Callable[[VarArg(Any), KwArg(Any)], Never]]"; expected "tuple[type[Any], ...]"  [arg-type]

schema_salad (https://github.com/common-workflow-language/schema_salad)
+ schema_salad/python_codegen_support.py: note: In member "__init__" of class "_PrimitiveLoader":
+ schema_salad/python_codegen_support.py:440:34: error: Missing type parameters for generic type "type"  [type-arg]
+ schema_salad/metaschema.py: note: In member "__init__" of class "_PrimitiveLoader":
+ schema_salad/metaschema.py:443:34: error: Missing type parameters for generic type "type"  [type-arg]

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ src/hydra_zen/funcs.py:102: error: "Any" not callable  [misc]
- src/hydra_zen/structured_configs/_implementations.py:2833: error: Argument 1 to "append" of "list" has incompatible type "tuple[str, Any]"; expected "tuple[str, type, Field[Any]]"  [arg-type]
+ src/hydra_zen/structured_configs/_implementations.py:2833: error: Argument 1 to "append" of "list" has incompatible type "tuple[str, Any]"; expected "tuple[str, type[Any], Field[Any]]"  [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:2921: error: Argument "type_" to "_retain_type_info" has incompatible type "str | Any"; expected "type"  [arg-type]
+ src/hydra_zen/structured_configs/_implementations.py:2921: error: Argument "type_" to "_retain_type_info" has incompatible type "str | Any"; expected "type[Any]"  [arg-type]
- src/hydra_zen/structured_configs/_implementations.py:3238: error: List comprehension has incompatible type List[tuple[str, Any | <typing special form>, Any | Field[Any]]]; expected List[tuple[str, type] | tuple[str, type, Any]]  [misc]
+ src/hydra_zen/structured_configs/_implementations.py:3238: error: List comprehension has incompatible type List[tuple[str, Any | <typing special form>, Any | Field[Any]]]; expected List[tuple[str, type[Any]] | tuple[str, type[Any], Any]]  [misc]

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/compat.py:106: error: Missing type parameters for generic type "type"  [type-arg]
+ src/_pytest/mark/structures.py:267: error: Missing type parameters for generic type "type"  [type-arg]
+ src/_pytest/mark/structures.py:365: error: Missing type parameters for generic type "type"  [type-arg]
+ src/_pytest/fixtures.py:176: error: Missing type parameters for generic type "type"  [type-arg]
+ src/_pytest/fixtures.py:1470: error: Missing type parameters for generic type "type"  [type-arg]
+ src/_pytest/unittest.py:115: error: Missing type parameters for generic type "type"  [type-arg]
+ src/_pytest/unittest.py:171: error: Missing type parameters for generic type "type"  [type-arg]

rich (https://github.com/Textualize/rich)
+ rich/protocol.py:30: error: Missing type parameters for generic type "type"  [type-arg]
+ rich/pretty.py:162: error: Missing type parameters for generic type "type"  [type-arg]
+ rich/pretty.py:379: error: Missing type parameters for generic type "type"  [type-arg]
+ rich/abc.py:16: error: Missing type parameters for generic type "type"  [type-arg]
+ rich/_inspect.py:236: error: Missing type parameters for generic type "type"  [type-arg]
+ rich/prompt.py:44: error: Missing type parameters for generic type "type"  [type-arg]

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ tests/__init__.py:40: error: Unused "type: ignore" comment  [unused-ignore]
+ tests/__init__.py:58: error: Unused "type: ignore" comment  [unused-ignore]

trio (https://github.com/python-trio/trio)
+ src/trio/_tests/test_exports.py:83: error: Missing type parameters for generic type "type"  [type-arg]

steam.py (https://github.com/Gobot1234/steam.py)
- steam/id.py:237: error: Need type annotation for "__class_getitem__"  [var-annotated]

discord.py (https://github.com/Rapptz/discord.py)
- discord/utils.py:745: error: "type" has no attribute "__slots__"  [attr-defined]

pwndbg (https://github.com/pwndbg/pwndbg)
+ pwndbg/aglib/dynamic.py: note: In class "CStruct":
+ pwndbg/aglib/dynamic.py:629: error: Missing type parameters for generic type "type"  [type-arg]
+ pwndbg/aglib/dynamic.py: note: In member "__init__" of class "CStruct":
+ pwndbg/aglib/dynamic.py:751: error: Missing type parameters for generic type "type"  [type-arg]

jax (https://github.com/google/jax)
+ jax/_src/dtypes.py:363: error: Unused "type: ignore" comment  [unused-ignore]
+ jax/_src/dtypes.py:364: error: Unused "type: ignore" comment  [unused-ignore]

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/operations/udf.py:155: error: Argument 2 to "type" has incompatible type "tuple[Callable[[_UDF], type[B]]]"; expected "tuple[type, ...]"  [arg-type]
+ ibis/expr/operations/udf.py:155: error: Argument 2 to "type" has incompatible type "tuple[Callable[[_UDF], type[B]]]"; expected "tuple[type[Any], ...]"  [arg-type]
- ibis/expr/operations/core.py:45: note:          def __coerce__(cls, value: Any, T: type | None = ..., S: type | None = ...) -> Value[T, S]
+ ibis/expr/operations/core.py:45: note:          def __coerce__(cls, value: Any, T: type[Any] | None = ..., S: type[Any] | None = ...) -> Value[T, S]

core (https://github.com/home-assistant/core)
+ homeassistant/helpers/deprecation.py:374: error: Missing type parameters for generic type "type"  [type-arg]
+ homeassistant/helpers/entity.py:286: error: Missing type parameters for generic type "type"  [type-arg]
+ homeassistant/helpers/entity.py:301: error: Missing type parameters for generic type "type"  [type-arg]

kornia (https://github.com/kornia/kornia)
+ kornia/contrib/models/efficient_vit/nn/norm.py:24: error: Missing type parameters for generic type "type"  [type-arg]
+ kornia/core/check.py:121: error: Missing type parameters for generic type "type"  [type-arg]

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/debug/repr.py:84: error: Missing type parameters for generic type "type"  [type-arg]
+ src/werkzeug/debug/repr.py:98: error: Missing type parameters for generic type "type"  [type-arg]
+ src/werkzeug/_internal.py:150: error: Missing type parameters for generic type "type"  [type-arg]
+ src/werkzeug/_internal.py:154: error: Missing type parameters for generic type "type"  [type-arg]
+ src/werkzeug/_internal.py:157: error: Missing type parameters for generic type "type"  [type-arg]
+ src/werkzeug/local.py:310: error: Missing type parameters for generic type "type"  [type-arg]
+ src/werkzeug/middleware/lint.py:41: error: Missing type parameters for generic type "type"  [type-arg]

graphql-core (https://github.com/graphql-python/graphql-core)
+ src/graphql/language/ast.py:426: error: Unused "type: ignore" comment  [unused-ignore]

antidote (https://github.com/Finistere/antidote)
+ src/antidote/_internal/typing.py:24: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/_internal/typing.py:41: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/_internal/typing.py:42: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/_internal/typing.py:49: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/_internal/typing.py:53: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/_internal/typing.py:59: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/exceptions.py:77: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/exceptions.py:88: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/data.py:218: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/_raw/wrapper.py:70: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/_raw/wrapper.py:96: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/_raw/wrapper.py:114: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/_raw/wrapper.py:130: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/_raw/wrapper.py:148: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/wiring.py:29: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/wiring.py:163: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/_wiring.py:21: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/_scope.py:65: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/_inject.py:49: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/__init__.py:1308: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/__init__.py:1312: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/__init__.py:1316: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/core/__init__.py:1319: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/lazy_ext/_provider.py:122: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/injectable_ext/_provider.py:16: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/lazy_ext/_lazy.py:285: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/lazy_ext/_lazy.py:345: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/lazy_ext/_const.py:173: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/injectable_ext/_internal.py:9: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/injectable_ext/_internal.py:16: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/injectable_ext/_internal.py:26: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/injectable_ext/_internal.py:34: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/injectable_ext/_internal.py:36: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/lazy_ext/__init__.py:607: error: Missing type parameters for generic type "type"  [type-arg]
+ src/antidote/lib/interface_ext/_interface.py:583: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/internal/test_utils.py:60: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/core/test_wiring.py:24: error: Missing type parameters for generic type "type"  [type-arg]
+ tests/core/test_wiring.py:59: error: Missing type parameters for generic type "type"  [type-arg]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent narrowing for builtins.type and typing.Type
3 participants