Skip to content

Make all names and fullnames into properties #7829

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 3 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
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
Fix some indentation errors
  • Loading branch information
msullivan committed Nov 13, 2019
commit 4d2674fdb5b1d53be55c6c0e4c231ab50e54d72e
28 changes: 16 additions & 12 deletions misc/proper_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,24 @@ def is_special_target(right: ProperType) -> bool:
if right.type_object().fullname == 'builtins.tuple':
# Used with Union[Type, Tuple[Type, ...]].
return True
if right.type_object().fullname in ('mypy.types.Type',
'mypy.types.ProperType',
'mypy.types.TypeAliasType'):
if right.type_object().fullname in (
'mypy.types.Type',
'mypy.types.ProperType',
'mypy.types.TypeAliasType'
):
# Special case: things like assert isinstance(typ, ProperType) are always OK.
return True
if right.type_object().fullname in ('mypy.types.UnboundType',
'mypy.types.TypeVarType',
'mypy.types.RawExpressionType',
'mypy.types.EllipsisType',
'mypy.types.StarType',
'mypy.types.TypeList',
'mypy.types.CallableArgument',
'mypy.types.PartialType',
'mypy.types.ErasedType'):
if right.type_object().fullname in (
'mypy.types.UnboundType',
'mypy.types.TypeVarType',
'mypy.types.RawExpressionType',
'mypy.types.EllipsisType',
'mypy.types.StarType',
'mypy.types.TypeList',
'mypy.types.CallableArgument',
'mypy.types.PartialType',
'mypy.types.ErasedType'
):
# Special case: these are not valid targets for a type alias and thus safe.
# TODO: introduce a SyntheticType base to simplify this?
return True
Expand Down
6 changes: 4 additions & 2 deletions mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4455,8 +4455,10 @@ def builtin_item_type(tp: Type) -> Optional[Type]:
tp = get_proper_type(tp)

if isinstance(tp, Instance):
if tp.type.fullname in ['builtins.list', 'builtins.tuple', 'builtins.dict',
'builtins.set', 'builtins.frozenset']:
if tp.type.fullname in [
'builtins.list', 'builtins.tuple', 'builtins.dict',
'builtins.set', 'builtins.frozenset',
]:
if not tp.args:
# TODO: fix tuple in lib-stub/builtins.pyi (it should be generic).
return None
Expand Down
3 changes: 1 addition & 2 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,8 +1418,7 @@ def format(typ: Type) -> str:
if isinstance(typ, Instance):
itype = typ
# Get the short name of the type.
if itype.type.fullname in ('types.ModuleType',
'_importlib_modulespec.ModuleType'):
if itype.type.fullname in ('types.ModuleType', '_importlib_modulespec.ModuleType'):
# Make some common error messages simpler and tidier.
return 'Module'
if verbosity >= 2 or (fullnames and itype.type.fullname in fullnames):
Expand Down
6 changes: 2 additions & 4 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,8 +1241,7 @@ class Foo(Bar, Generic[T]): ...
if isinstance(base, UnboundType):
sym = self.lookup_qualified(base.name, base)
if sym is not None and sym.node is not None:
if (sym.node.fullname in ('typing.Protocol',
'typing_extensions.Protocol') and
if (sym.node.fullname in ('typing.Protocol', 'typing_extensions.Protocol') and
i not in removed):
# also remove bare 'Protocol' bases
removed.append(i)
Expand Down Expand Up @@ -3071,8 +3070,7 @@ def is_final_type(self, typ: Optional[Type]) -> bool:
sym = self.lookup_qualified(typ.name, typ)
if not sym or not sym.node:
return False
return sym.node.fullname in ('typing.Final',
'typing_extensions.Final')
return sym.node.fullname in ('typing.Final', 'typing_extensions.Final')

def fail_invalid_classvar(self, context: Context) -> None:
self.fail('ClassVar can only be used for assignments in class body', context)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy