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

Use X | Y union syntax in error messages #15102

Merged
merged 8 commits into from
Apr 24, 2023
Prev Previous commit
Next Next commit
Fix formatting
  • Loading branch information
omarsilva1 committed Apr 23, 2023
commit 2d8120f2858368b785336bff7665c8f2b96e539a
8 changes: 4 additions & 4 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2360,10 +2360,10 @@ def format_list(types: Sequence[Type]) -> str:
return ", ".join(format(typ) for typ in types)

def format_union(types: Sequence[Type]) -> str:
new_list = [format(typ) for typ in types if format(typ) is not "None"]
if any(format(typ) is "None" for typ in types):
new_list.append("None")
return " | ".join(new_list)
formatted = [format(typ) for typ in types if format(typ) != "None"]
if any(format(typ) == "None" for typ in types):
formatted.append("None")
return " | ".join(formatted)

def format_literal_value(typ: LiteralType) -> str:
if typ.is_enum_literal():
Expand Down