From 2aa46bbfa23cf37ddba581079b8ee9b749480498 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Tue, 27 Jun 2023 00:56:40 -0700 Subject: [PATCH 1/3] Fix find occurrences flag Fixes #15527 Namespaces are untyped, so this only gets caught by mypyc. I didn't know about this feature, looks like it's explicitly documented as experimental. Guess no one has used it in a long, long time. --- mypy/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/main.py b/mypy/main.py index b60c5b2a6bba..11647362d1b4 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -1336,7 +1336,7 @@ def set_strict_flags() -> None: # Set build flags. if special_opts.find_occurrences: - state.find_occurrences = special_opts.find_occurrences.split(".") + state.find_occurrences = tuple(special_opts.find_occurrences.split(".")) assert state.find_occurrences is not None if len(state.find_occurrences) < 2: parser.error("Can only find occurrences of class members.") From 558b5c308bcdcfd110ba4e4806ae2e50ddb22bbc Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Tue, 27 Jun 2023 10:58:24 -0700 Subject: [PATCH 2/3] fix type error --- mypy/main.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mypy/main.py b/mypy/main.py index 11647362d1b4..9af809987782 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -1336,12 +1336,13 @@ def set_strict_flags() -> None: # Set build flags. if special_opts.find_occurrences: - state.find_occurrences = tuple(special_opts.find_occurrences.split(".")) - assert state.find_occurrences is not None - if len(state.find_occurrences) < 2: + _find_occurrences = tuple(special_opts.find_occurrences.split(".")) + assert _find_occurrences is not None + if len(_find_occurrences) < 2: parser.error("Can only find occurrences of class members.") - if len(state.find_occurrences) != 2: + if len(_find_occurrences) != 2: parser.error("Can only find occurrences of non-nested class members.") + state.find_occurrences = _find_occurrences # type: ignore[assignment] # Set reports. for flag, val in vars(special_opts).items(): From 1faca091f1bf6756bf422f0b0cd6b83e9a587e5c Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Tue, 27 Jun 2023 13:01:56 -0700 Subject: [PATCH 3/3] remove assert --- mypy/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mypy/main.py b/mypy/main.py index 9af809987782..e7c783c39c58 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -1337,7 +1337,6 @@ def set_strict_flags() -> None: # Set build flags. if special_opts.find_occurrences: _find_occurrences = tuple(special_opts.find_occurrences.split(".")) - assert _find_occurrences is not None if len(_find_occurrences) < 2: parser.error("Can only find occurrences of class members.") if len(_find_occurrences) != 2: