Skip to content
Merged
Changes from 1 commit
Commits
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
Fix accidentaly uncovered NewType bug
  • Loading branch information
ilevkivskyi committed Aug 10, 2022
commit 2dfd5c2e6277f615c4448dbd4dbd9929bbccf33b
5 changes: 4 additions & 1 deletion mypy/semanal_newtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def process_newtype_declaration(self, s: AssignmentStmt) -> bool:
old_type = get_proper_type(old_type)
if not call.analyzed:
call.analyzed = NewTypeExpr(var_name, old_type, line=call.line, column=call.column)
else:
call.analyzed.old_type = old_type
if old_type is None:
if should_defer:
# Base type is not ready.
Expand Down Expand Up @@ -230,6 +232,7 @@ def build_newtype_typeinfo(
existing_info: Optional[TypeInfo],
) -> TypeInfo:
info = existing_info or self.api.basic_new_typeinfo(name, base_type, line)
info.bases = [base_type] # Update in case there were nested placeholders.
info.is_newtype = True

# Add __init__ method
Expand All @@ -250,7 +253,7 @@ def build_newtype_typeinfo(
init_func._fullname = info.fullname + ".__init__"
info.names["__init__"] = SymbolTableNode(MDEF, init_func)

if info.tuple_type and has_placeholder(info.tuple_type):
if has_placeholder(old_type) or info.tuple_type and has_placeholder(info.tuple_type):
self.api.defer(force_progress=True)
return info

Expand Down