8000 Refactor: replace make_simplified_union with UnionType.make_union (#8624) by lsrafael13 · Pull Request #19026 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Refactor: replace make_simplified_union with UnionType.make_union (#8624) #19026

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

Closed
wants to merge 18 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ea923b4
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
34f3387
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
f469a4c
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
50afb03
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
ec2f254
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
4ad5492
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
65e00ff
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
3c29b1d
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
fc16c07
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
4cb17eb
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
34930f8
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
404d839
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
b5218d6
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
cdc64c0
Refactor: replace make_simplified_union with UnionType.make_union in …
lsrafael13 May 4, 2025
1f1bc26
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 4, 2025
0f9e25e
style: apply formatting fixes using ruff and black
lsrafael13 May 4, 2025
795baca
Merge branch 'issue-8624-refactor' of https://github.com/lsrafael13/m…
lsrafael13 May 4, 2025
acb71a3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor: replace make_simplified_union with UnionType.make_union in …
…meet.py (#8624)

This commit replaces all calls to make_simplified_union with UnionType.make_union in this file, as part of the codebase modernization effort in issue #8624.
  • Loading branch information
lsrafael13 committed May 4, 2025
commit 65e00ffae66ba9b2ad2a0f78dbfbaeab6a365a0c
8 changes: 4 additions & 4 deletions mypy/meet.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def narrow_declared_type(declared: Type, narrowed: Type) -> Type:
if declared == narrowed:
return original_declared
if isinstance(declared, UnionType):
return make_simplified_union(
return UnionType.make_union(
[
narrow_declared_type(x, narrowed)
for x in declared.relevant_items()
Expand All @@ -146,7 +146,7 @@ def narrow_declared_type(declared: Type, narrowed: Type) -> Type:
# Quick check before reaching `is_overlapping_types`. If it's enum/literal overlap,
# avoid full expansion and make it faster.
assert isinstance(narrowed, UnionType)
return make_simplified_union(
return UnionType.make_union(
[narrow_declared_type(declared, x) for x in narrowed.relevant_items()]
)
elif not is_overlapping_types(declared, narrowed, prohibit_none_typevar_overlap=True):
Expand All @@ -155,7 +155,7 @@ def narrow_declared 7775 _type(declared: Type, narrowed: Type) -> Type:
else:
return NoneType()
elif isinstance(narrowed, UnionType):
return make_simplified_union(
return UnionType.make_union(
[narrow_declared_type(declared, x) for x in narrowed.relevant_items()]
)
elif isinstance(narrowed, AnyType):
Expand Down Expand Up @@ -745,7 +745,7 @@ def visit_union_type(self, t: UnionType) -> ProperType:
meets.append(meet_types(x, y))
else:
meets = [meet_types(x, self.s) for x in t.items]
return make_simplified_union(meets)
return UnionType.make_union(meets)

def visit_none_type(self, t: NoneType) -> ProperType:
if state.strict_optional:
Expand Down
0