@@ -2410,15 +2410,6 @@ def lookup_operator(op_name: str, base_type: Type) -> Optional[Type]:
2410
2410
"""Looks up the given operator and returns the corresponding type,
2411
2411
if it exists."""
2412
2412
local_errors = make_local_errors ()
2413
-
2414
- # TODO: Remove this call and rely just on analyze_member_access
2415
- # Currently, it seems we still need this to correctly deal with
2416
- # things like metaclasses?
2417
- #
2418
- # E.g. see the pythoneval.testMetaclassOpAccessAny test case.
2419
- if not self .has_member (base_type , op_name ):
2420
- return None
2421
-
2422
2413
member = analyze_member_access (
2423
2414
name = op_name ,
2424
2415
typ = base_type ,
@@ -3799,43 +3790,6 @@ def is_valid_keyword_var_arg(self, typ: Type) -> bool:
3799
3790
[self .named_type ('builtins.unicode' ),
3800
3791
AnyType (TypeOfAny .special_form )])))
3801
3792
3802
- def has_member (self , typ : Type , member : str ) -> bool :
3803
- """Does type have member with the given name?"""
3804
- # TODO: refactor this to use checkmember.analyze_member_access, otherwise
3805
- # these two should be carefully kept in sync.
3806
- typ = get_proper_type (typ )
3807
-
3808
- if isinstance (typ , TypeVarType ):
3809
- typ = get_proper_type (typ .upper_bound )
3810
- if isinstance (typ , TupleType ):
3811
- typ = tuple_fallback (typ )
3812
- if isinstance (typ , LiteralType ):
3813
- typ = typ .fallback
3814
- if isinstance (typ , Instance ):
3815
- return typ .type .has_readable_member (member )
3816
- if isinstance (typ , CallableType ) and typ .is_type_obj ():
3817
- return typ .fallback .type .has_readable_member (member )
3818
- elif isinstance (typ , AnyType ):
3819
- return True
3820
- elif isinstance (typ , UnionType ):
3821
- result = all (self .has_member (x , member ) for x in typ .relevant_items ())
3822
- return result
3823
- elif isinstance (typ , TypeType ):
3824
- # Type[Union[X, ...]] is always normalized to Union[Type[X], ...],
3825
- # so we don't need to care about unions here.
3826
- item = typ .item
3827
- if isinstance (item , TypeVarType ):
3828
- item = get_proper_type (item .upper_bound )
3829
- if isinstance (item , TupleType ):
3830
- item = tuple_fallback (item )
3831
- if isinstance (item , Instance ) and item .type .metaclass_type is not None :
3832
- return self .has_member (item .type .metaclass_type , member )
3833
- if isinstance (item , AnyType ):
3834
- return True
3835
- return False
3836
- else :
3837
- return False
3838
-
3839
3793
def not_ready_callback (self , name : str , context : Context ) -> None :
3840
3794
"""Called when we can't infer the type of a variable because it's not ready yet.
3841
3795
0 commit comments