From 1ee28d8afbe59c326c5576c93ec5625d09067add Mon Sep 17 00:00:00 2001 From: Sneha Nair <150941178+Snehaaa24@users.noreply.github.com> Date: Tue, 14 Jan 2025 16:25:54 +0530 Subject: [PATCH 1/3] added explicit checks for None before calling obj_type() to prevent errors if obj_type is None. --- mypy/mro.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mypy/mro.py b/mypy/mro.py index f34f3fa0c46d..01786c659428 100644 --- a/mypy/mro.py +++ b/mypy/mro.py @@ -32,8 +32,7 @@ def linearize_hierarchy( return info.mro bases = info.direct_base_classes() if not bases and info.fullname != "builtins.object" and obj_type is not None: - # Probably an error, add a dummy `object` base class, - # otherwise MRO calculation may spuriously fail. + # If no base classes are found, and obj_type is provided, we use obj_type to provide a base. bases = [obj_type().type] lin_bases = [] for base in bases: From f28a47f2584d92ae338bbf7e9069fb61091e3f28 Mon Sep 17 00:00:00 2001 From: Sneha Nair <150941178+Snehaaa24@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:22:50 +0530 Subject: [PATCH 2/3] Adding some more checks for None. --- misc/analyze_cache.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/misc/analyze_cache.py b/misc/analyze_cache.py index 0a05493b77a3..8bf618eb8111 100644 --- a/misc/analyze_cache.py +++ b/misc/analyze_cache.py @@ -77,6 +77,8 @@ def pluck(name: str, chunks: Iterable[JsonDict]) -> Iterable[JsonDict]: def report_counter(counter: Counter[str], amount: int | None = None) -> None: + if amount is None: + amount=len(counter) #default to the length of the counter if `amount` is None for name, count in counter.most_common(amount): print(f" {count: <8} {name}") print() From eee7f691e7c963bd4ffba3f7a1587de7715e1a3c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 14:05:11 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- misc/analyze_cache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/analyze_cache.py b/misc/analyze_cache.py index 8bf618eb8111..f67e9b0ba753 100644 --- a/misc/analyze_cache.py +++ b/misc/analyze_cache.py @@ -78,7 +78,7 @@ def pluck(name: str, chunks: Iterable[JsonDict]) -> Iterable[JsonDict]: def report_counter(counter: Counter[str], amount: int | None = None) -> None: if amount is None: - amount=len(counter) #default to the length of the counter if `amount` is None + amount = len(counter) # default to the length of the counter if `amount` is None for name, count in counter.most_common(amount): print(f" {count: <8} {name}") print()