8000 Add plugin to infer more precise regex match types by Michael0x2a · Pull Request #7803 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Add plugin to infer more precise regex match types #7803

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
Next Next commit
Fix
  • Loading branch information
97littleleaf11 committed Jan 5, 2022
commit 45168cd7fa4118b0c25efd30844f3be8d081bf84
2 changes: 1 addition & 1 deletion mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4988,7 +4988,7 @@ def named_generic_type(self, name: str, args: List[Type]) -> Instance:
the name refers to a compatible generic type.
"""
info = self.lookup_typeinfo(name)
args = [remove_instance_last_known_values(arg) for arg in args]
args = [remove_instance_transient_info(arg) for arg in args]
# TODO: assert len(args) == len(info.defn.type_vars)
return Instance(info, args)

Expand Down
4 changes: 2 additions & 2 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import mypy.checker
from mypy import types
from mypy.sametypes import is_same_type
from mypy.erasetype import replace_meta_vars, erase_type, remove_instance_last_known_values
from mypy.erasetype import replace_meta_vars, erase_type, remove_instance_transient_info
from mypy.maptype import map_instance_to_supertype
from mypy.messages import MessageBuilder
from mypy import message_registry
Expand Down Expand Up @@ -3334,7 +3334,7 @@ def check_lst_expr(self, items: List[Expression], fullname: str,
[(nodes.ARG_STAR if isinstance(i, StarExpr) else nodes.ARG_POS)
for i in items],
context)[0]
return remove_instance_last_known_values(out)
return remove_instance_transient_info(out)

def visit_tuple_expr(self, e: TupleExpr) -> Type:
"""Type check a tuple expression."""
Expand Down
2 changes: 0 additions & 2 deletions mypy/typeops.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import itertools
import sys

import sys

from mypy.types import (
TupleType, Instance, FunctionLike, Type, CallableType, TypeVarLikeType, Overloaded,
TypeVarType, UninhabitedType, FormalArgument, UnionType, NoneType,
Expand Down
2 changes: 1 addition & 1 deletion mypy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ def __init__(self, typ: mypy.nodes.TypeInfo, args: Sequence[Type],
# this instance, if one is known.
#
# This field is set whenever possible within expressions, but is erased upon
# variable assignment (see erasetype.remove_instance_last_known_values) unless
# variable assignment (see erasetype.remove_instance_transient_info) unless
# the variable is declared to be final.
#
# For example, consider the following program:
Expand Down
0