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
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
Fix lint error
  • Loading branch information
MichaelLeeDBX committed Jul 27, 2016
commit e8b1cd64f03df0c9368fca7cef8355592575821b
12 changes: 6 additions & 6 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,12 +1333,12 @@ def build_newtype_typeinfo(self, name: str, value: Instance) -> TypeInfo:
args = [Argument(Var('cls'), NoneTyp(), None, ARG_POS),
self.make_argument('item', value)]
signature = CallableType(
arg_types = [cast(Type, None), value],
arg_kinds = [arg.kind for arg in args],
arg_names = ['self', 'item'],
ret_type = value,
fallback = self.named_type('__builtins__.function'),
name = info.name())
arg_types = [cast(Type, None), value],
arg_kinds = [arg.kind for arg in args],
arg_names = ['self', 'item'],
ret_type = value,
fallback = self.named_type('__builtins__.function'),
name = info.name())
init_func = FuncDef('__init__', args, Block([]), typ=signature)
init_func.info = info
symbols['__init__'] = SymbolTableNode(MDEF, init_func)
Expand Down
0