Skip to content
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4ac02d5
Handle NotImplemented from __ne__; improve test cases
kamahen Mar 20, 2018
dafce6c
Handle NotImplemented from __ne__; improve test cases
kamahen Mar 20, 2018
4dfae58
Merge branch 'master' of https://github.com/kamahen/mypy
kamahen Mar 20, 2018
c084266
Handle NotImplemented from __ne__; improve test cases
kamahen Mar 20, 2018
2a1bd83
adjusted comment in test to remove reference to pylint
kamahen Mar 20, 2018
bc76eed
added more __xxx__ methods and tests
kamahen Mar 21, 2018
7ce5488
Refactored sets of magic methods to make it more obvious what changes…
kamahen Mar 27, 2018
6176031
revert sharedparse.py and add only __ne__; comment out tests that fail
kamahen Mar 27, 2018
e969ca2
Removed commented-out tests that currently fail (they'll be dealt wit…
kamahen Mar 27, 2018
a5c1c7f
Merge branch 'master' of git://github.com/python/mypy
kamahen Mar 28, 2018
67b979f
remove extra tests; these will be handled separately
kamahen Mar 28, 2018
70ef593
Merge branch 'master' of git://github.com/python/mypy
kamahen Mar 28, 2018
93effd1
Merge branch 'master' of git://github.com/python/mypy
kamahen Mar 29, 2018
cceda9f
Merge branch 'master' of git://github.com/python/mypy
kamahen Mar 31, 2018
a0606ef
Merge remote-tracking branch 'upstream/master'
kamahen Apr 2, 2018
515d2ab
Refactor "magic" method constants so that there are no dups
kamahen Apr 2, 2018
d02f433
Merge branch 'master' of git://github.com/python/mypy
kamahen Apr 2, 2018
9f823ce
Merge branch 'master' of git://github.com/python/mypy
kamahen Apr 4, 2018
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
54 changes: 7 additions & 47 deletions mypy/sharedparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,39 @@
"""Shared logic between our three mypy parser files."""


MAGIC_METHODS = {
_NON_BINARY_MAGIC_METHODS = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd drop the initial underscore here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_NON_BINARY_MAGIC_METHODS isn't used anywhere else and its existence is a side-effect of the implementation, so I'd rather leave the initial underscore if you don't mind. If someone wants to use this value in future, they can always remove the initial underscore at that time.

"__abs__",
"__add__",
"__and__",
"__call__",
"__cmp__",
"__complex__",
"__contains__",
"__del__",
"__delattr__",
"__delitem__",
"__divmod__",
"__div__",
"__enter__",
"__exit__",
"__eq__",
"__floordiv__",
"__float__",
"__ge__",
"__getattr__",
"__getattribute__",
"__getitem__",
"__gt__",
"__hex__",
"__iadd__",
"__iand__",
"__idiv__",
"__ifloordiv__",
"__ilshift__",
"__imod__",
"__imul__",
"__init__",
"__init_subclass__",
"__int__",
"__invert__",
"__ior__",
"__ipow__",
"__irshift__",
"__isub__",
"__iter__",
"__ixor__",
"__le__",
"__len__",
"__long__",
"__lshift__",
"__lt__",
"__mod__",
"__mul__",
"__ne__",
"__neg__",
"__new__",
"__nonzero__",
"__oct__",
"__or__",
"__pos__",
"__pow__",
"__radd__",
"__rand__",
"__rdiv__",
"__repr__",
"__reversed__",
"__rfloordiv__",
"__rlshift__",
"__rmod__",
"__rmul__",
"__ror__",
"__rpow__",
"__rrshift__",
"__rshift__",
"__rsub__",
"__rxor__",
"__setattr__",
"__setitem__",
"__str__",
"__sub__",
"__unicode__",
"__xor__",
}

MAGIC_METHODS_ALLOWING_KWARGS = {
Expand All @@ -89,8 +45,6 @@
"__call__",
}

MAGIC_METHODS_POS_ARGS_ONLY = MAGIC_METHODS - MAGIC_METHODS_ALLOWING_KWARGS

BINARY_MAGIC_METHODS = {
"__add__",
"__and__",
Expand Down Expand Up @@ -138,6 +92,12 @@
"__xor__",
}

assert not (_NON_BINARY_MAGIC_METHODS & BINARY_MAGIC_METHODS)

MAGIC_METHODS = _NON_BINARY_MAGIC_METHODS | BINARY_MAGIC_METHODS

MAGIC_METHODS_POS_ARGS_ONLY = MAGIC_METHODS - MAGIC_METHODS_ALLOWING_KWARGS


def special_function_elide_names(name: str) -> bool:
return name in MAGIC_METHODS_POS_ARGS_ONLY
Expand Down