Skip to content

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Nov 18, 2022

Easy crash to repro: mypy --any-exprs-report=out -c 'pass' --show-traceback

@hauntsaninja
Copy link
Collaborator Author

hauntsaninja commented Nov 18, 2022

  File "/Users/shantanu/dev/mypy/mypy/type_visitor.py", line 409, in visit_type_alias_type
    return get_proper_type(t).accept(self)
  File "/Users/shantanu/dev/mypy/mypy/types.py", line 1791, in accept
    return visitor.visit_callable_type(self)
  File "/Users/shantanu/dev/mypy/mypy/type_visitor.py", line 374, in visit_callable_type
    return self.query_types(t.arg_types + [t.ret_type])
  File "/Users/shantanu/dev/mypy/mypy/typeanal.py", line 1934, in query_types
    return self.strategy([t.accept(self) for t in types]) + list(types)
  File "/Users/shantanu/dev/mypy/mypy/typeanal.py", line 1934, in <listcomp>
    return self.strategy([t.accept(self) for t in types]) + list(types)
  File "/Users/shantanu/dev/mypy/mypy/types.py", line 2594, in accept
    return visitor.visit_union_type(self)
  File "/Users/shantanu/dev/mypy/mypy/type_visitor.py", line 392, in visit_union_type
    return self.query_types(t.items)
  File "/Users/shantanu/dev/mypy/mypy/typeanal.py", line 1934, in query_types
    return self.strategy([t.accept(self) for t in types]) + list(types)
  File "/Users/shantanu/dev/mypy/mypy/typeanal.py", line 1934, in <listcomp>
    return self.strategy([t.accept(self) for t in types]) + list(types)
  File "/Users/shantanu/dev/mypy/mypy/types.py", line 321, in accept
    return visitor.visit_type_alias_type(self)
...
RecursionError

@hauntsaninja hauntsaninja merged commit b650d96 into python:master Nov 18, 2022
@hauntsaninja hauntsaninja deleted the revert-type branch November 18, 2022 09:49
@github-actions
Copy link
Contributor

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

discord.py (https://github.com/HitSyr/discord.py)
- discord/ext/commands/converter.py:1177: error: Argument 2 to "issubclass" has incompatible type "<typing special form>"; expected "_ClassInfo"  [arg-type]
+ discord/ext/commands/converter.py:1177: error: Argument 2 to "issubclass" has incompatible type "<typing special form>"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]"  [arg-type]
- discord/ext/commands/hybrid.py:206: error: Argument 2 to "isinstance" has incompatible type "_SpecialForm"; expected "_ClassInfo"  [arg-type]
+ discord/ext/commands/hybrid.py:206: error: Argument 2 to "isinstance" has incompatible type "_SpecialForm"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]"  [arg-type]

@ilevkivskyi
Copy link
Member

@hauntsaninja I hope #14136 should help with this.

hauntsaninja pushed a commit that referenced this pull request Nov 19, 2022
See #14130 for context.

Btw it looks like these `Any` reports are quite broken in general. Some
issues I found:
* Many types are reported twice (even non-recursive)
* Explicit `Any` in alias r.h.s are not counted (because of reckless
`res = make_any_non_explicit(res)` in semanal.py)
* For generic aliases we count their r.h.s. as containing `Any` from
omitted generics

I tried to fix these things, but it is not trivial, so maybe we can do
it later in a separate PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants