Skip to content

Commit

Permalink
A bit of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dmontagu committed Dec 15, 2023
1 parent 4bf8299 commit 7db913f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pydantic/_internal/_generate_schema.py
Expand Up @@ -281,9 +281,8 @@ def tail(self) -> TypesNamespace:
return self._types_namespace_stack[-1]

@contextmanager
def push(self, for_type: type[Any], existing_types_namespace: TypesNamespace):
# Not sure whether we should really preserve/extend the existing types namespace or not
types_namespace = {**_typing_extra.get_cls_types_namespace(for_type), **(existing_types_namespace or {})}
def push(self, for_type: type[Any]):
types_namespace = {**_typing_extra.get_cls_types_namespace(for_type), **(self.tail or {})}
self._types_namespace_stack.append(types_namespace)
try:
yield
Expand Down Expand Up @@ -1142,7 +1141,7 @@ def _type_alias_type_schema(

annotation = origin.__value__
typevars_map = get_standard_typevars_map(obj)
with self._types_namespace_stack.push(origin, self._types_namespace):
with self._types_namespace_stack.push(origin):
annotation = _typing_extra.eval_type_lenient(annotation, self._types_namespace, None)
annotation = replace_types(annotation, typevars_map)
schema = self.generate_schema(annotation)
Expand Down Expand Up @@ -1448,9 +1447,7 @@ def _dataclass_schema(
dataclass = origin

config = getattr(dataclass, '__pydantic_config__', None)
with self._config_wrapper_stack.push(config), self._types_namespace_stack.push(
dataclass, self._types_namespace
):
with self._config_wrapper_stack.push(config), self._types_namespace_stack.push(dataclass):
core_config = self._config_wrapper.core_config(dataclass)

self = self._current_generate_schema
Expand Down

0 comments on commit 7db913f

Please sign in to comment.