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

Revert use of recursive alias in typeshed #14130

Merged
merged 1 commit into from
Nov 18, 2022

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