Skip to content

Fix daemon crash on malformed NamedTuple (#14119)#1

Merged
ChristianWitzler merged 10 commits intoChristianWitzler:masterfrom
python:master
Nov 21, 2022
Merged

Fix daemon crash on malformed NamedTuple (#14119)#1
ChristianWitzler merged 10 commits intoChristianWitzler:masterfrom
python:master

Conversation

@ChristianWitzler
Copy link
Copy Markdown
Owner

Fixes python#14098

Having invalid statements in a NamedTuple is almost like a syntax error, we can remove them after giving an error (without further analysis). This PR does almost exactly the same as
python#13963 did for TypedDicts.

Co-authored-by: Shantanu 12621235+hauntsaninja@users.noreply.github.com

(Explain how this PR changes mypy.)

ilevkivskyi and others added 10 commits November 18, 2022 10:48
Fixes #14098 

Having invalid statements in a NamedTuple is almost like a syntax error,
we can remove them after giving an error (without further analysis).
This PR does almost exactly the same as
#13963 did for TypedDicts.

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Fixes #12483
Fixes python/typeshed#7564
Ref #12841

The fix is straightforward. I can't use a unit test for this because
there are some builtins fixtures that don't have tuple, so I can't do
version check.
- Added missing cast import
- Changed revealed type

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
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.
#14148)

Fixes #14137 

Fix is trivial, I just forgot to call `super()` in one of my previous
PRs.
While working on another PR I noticed that current behavior of
`has_recursive_types()` is inconsistent, it returns `False` is there is
a recursive type nested as an argument to a generic non-recursive alias.
I wasn't able to find any situation where this actually matters, but I
think it is better if this function behaves consistently.
@ChristianWitzler ChristianWitzler merged commit 1cd9216 into ChristianWitzler:master Nov 21, 2022
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.

Mypy Deamon crash on second run

4 participants