8000 Add NewType by Michael0x2a · Pull Request #1939 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Add NewType #1939

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

Merged
merged 26 commits into from
Jul 28, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
965531f
Add NewVarExpr node
MichaelLeeDBX Jul 25, 2016
59471ce
Modify NameExpr, get prelim version working
MichaelLeeDBX Jul 25, 2016
a9c8205
Add basic tests for NewType
MichaelLeeDBX Jul 26, 2016
e8b1cd6
Fix lint error
MichaelLeeDBX Jul 26, 2016
582c651
Add is_newtype flag to nodes to mirror namedtuple
MichaelLeeDBX Jul 26, 2016
eea40bf
Add some incomplete tests for NewType
MichaelLeeDBX Jul 26, 2016
2f604a0
Add refinements to semantic analysis for NewType
MichaelLeeDBX Jul 26, 2016
868f90c
Fix error in tests
MichaelLeeDBX Jul 26, 2016
c31e01d
Add more tests
MichaelLeeDBX Jul 26, 2016
ccc1032
Modify NewType handling to fix bugs
MichaelLeeDBX Jul 26, 2016
b022eb3
Add tests to check for bad subtyping
MichaelLeeDBX Jul 26, 2016
06a4e9e
Modify semanal to catch bad subtyping with NewType
MichaelLeeDBX Jul 26, 2016
385a4b6
Add test for namedtuples
MichaelLeeDBX Jul 27, 2016
609746c
Add info about NewType to documentation
MichaelLeeDBX Jul 27, 2016
7967bcf
Remove unneeded code and imports
MichaelLeeDBX Jul 27, 2016
0daf486
Rearrange newtype tests to be more logical
MichaelLeeDBX Jul 27, 2016
d76b8da
Add test for NewType and Any
MichaelLeeDBX Jul 27, 2016
c81477d
Rename variables and combine checks in semanal
MichaelLeeDBX Jul 27, 2016
0995a30
Refactor newtype code in semenal
MichaelLeeDBX Jul 27, 2016
c37520b
Clarify info in documentation
MichaelLeeDBX Jul 28, 2016
0eb700a
Remove unnecessary extra code
MichaelLeeDBX Jul 28, 2016
90609af
Refactor semanal code
MichaelLeeDBX Jul 28, 2016
578c845
Fix lint errors
MichaelLeeDBX Jul 28, 2016
b273250
Fix tests based on new error message
MichaelLeeDBX Jul 28, 2016
c71aafa
Update tests for newtype to respond to code review
MichaelLeeDBX Jul 28, 2016
55617b9
Respond to 2nd wave of code review
MichaelLeeDBX Jul 28, 2016
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
Remove unnecessary extra code
  • Loading branch information
MichaelLeeDBX committed Jul 28, 2016
commit 0eb700aa68cd432f60fed35abcec601bdc4f97a3
5 changes: 1 addition & 4 deletions mypy/fixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from mypy.nodes import (MypyFile, SymbolNode, SymbolTable, SymbolTableNode,
TypeInfo, FuncDef, OverloadedFuncDef, Decorator, Var,
TypeVarExpr, NewTypeExpr, ClassDef,
TypeVarExpr, ClassDef,
LDEF, MDEF, GDEF, MODULE_REF)
from mypy.types import (CallableType, EllipsisType, Instance, Overloaded, TupleType,
TypeList, TypeVarType, UnboundType, UnionType, TypeVisitor,
Expand Down Expand Up @@ -123,9 +123,6 @@ def visit_type_var_expr(self, tv: TypeVarExpr) -> None:
value.accept(self.type_fixer)
tv.upper_bound.accept(self.type_fixer)

def visit_newtype_expr(self, nt: NewTypeExpr) -> None:
raise NotImplemented()

def visit_var(self, v: Var) -> None:
if self.current_info is not None:
v.info = self.current_info
Expand Down
2 changes: 1 addition & 1 deletion mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1989,7 +1989,7 @@ def serialize(self) -> Union[str, JsonDict]:
'_promote': None if self._promote is None else self._promote.serialize(),
'tuple_type': None if self.tuple_type is None else self.tuple_type.serialize(),
'is_named_tuple': self.is_named_tuple,
'is_newtype': self.is_newtype
'is_newtype': self.is_newtype,
}
return data

Expand Down
0