Skip to content

Commit

Permalink
Remove kwargs from issubclass.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark committed May 14, 2024
1 parent 7ce8da7 commit 43a9a86
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
8 changes: 2 additions & 6 deletions edb/edgeql/compiler/schemactx.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,9 +548,7 @@ def apply_intersection(
# of the argument, then this is, effectively, a NOP.
return TypeIntersectionResult(stype=left)

if right.issubclass(
ctx.env.schema, left, check_opaque_unions=True, check_views=True
):
if right.issubclass(ctx.env.schema, left):
# The intersection type is a proper *subclass* and can be directly
# narrowed.
return TypeIntersectionResult(
Expand All @@ -569,9 +567,7 @@ def apply_intersection(
is_empty: bool = (
not s_utils.expand_type_expr_descendants(int_type, ctx.env.schema)
)
is_subtype: bool = int_type.issubclass(
ctx.env.schema, left, check_opaque_unions=True, check_views=True,
)
is_subtype: bool = int_type.issubclass(ctx.env.schema, left)

return TypeIntersectionResult(
stype=int_type,
Expand Down
7 changes: 3 additions & 4 deletions edb/schema/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3025,19 +3025,18 @@ class SubclassableObject(Object):
)

def _issubclass(
self, schema: s_schema.Schema, parent: SubclassableObject, **kwargs: Any
self, schema: s_schema.Schema, parent: SubclassableObject
) -> bool:
return parent == self

def issubclass(
self,
schema: s_schema.Schema,
parent: Union[SubclassableObject, Tuple[SubclassableObject, ...]],
**kwargs: Any,
) -> bool:
from . import types as s_types
if isinstance(parent, tuple):
return any(self.issubclass(schema, p, **kwargs) for p in parent)
return any(self.issubclass(schema, p) for p in parent)
if (
isinstance(parent, s_types.Type)
and parent.is_anyobject(schema)
Expand All @@ -3048,7 +3047,7 @@ def issubclass(
if isinstance(parent, s_types.Type) and parent.is_any(schema):
return True

return self._issubclass(schema, parent, **kwargs)
return self._issubclass(schema, parent)


InheritingObjectT = TypeVar('InheritingObjectT', bound='InheritingObject')
Expand Down
8 changes: 3 additions & 5 deletions edb/schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,6 @@ def _issubclass(
self,
schema: s_schema.Schema,
parent: so.SubclassableObject,
**kwargs: Any,
) -> bool:
if isinstance(parent, Type) and parent.is_any(schema):
return True
Expand All @@ -1085,7 +1084,7 @@ def _issubclass(
for pt, my in zip(parent_types, my_types):
if (
not pt.is_any(schema)
and not my.issubclass(schema, pt, **kwargs)
and not my.issubclass(schema, pt)
):
return False

Expand All @@ -1098,15 +1097,14 @@ def issubclass(
so.SubclassableObject,
typing.Tuple[so.SubclassableObject, ...],
],
**kwargs: Any,
) -> bool:
if isinstance(parent, tuple):
return any(self.issubclass(schema, p, **kwargs) for p in parent)
return any(self.issubclass(schema, p) for p in parent)

if isinstance(parent, Type) and parent.is_any(schema):
return True

return self._issubclass(schema, parent, **kwargs)
return self._issubclass(schema, parent)

def get_subtypes(self, schema: s_schema.Schema) -> typing.Tuple[Type, ...]:
raise NotImplementedError
Expand Down

0 comments on commit 43a9a86

Please sign in to comment.