Redundant variables and unnecessary conditions were removed across several modules. Improved readability and reduced code complexity without changing functionality.
Closes: #12537
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12537
Pull-request-sha:
ab53f8c3487e8cfb4d4a0235c27d8a5b8557d193
Change-Id: I910d65729fdbc96933f9822c553924d37e89e201
# class already exists.
existing = decl_class_registry[classname]
if not isinstance(existing, _MultipleClassMarker):
- existing = decl_class_registry[classname] = _MultipleClassMarker(
+ decl_class_registry[classname] = _MultipleClassMarker(
[cls, cast("Type[Any]", existing)]
)
else:
else:
raise
else:
- existing = self.contents[name] = _MultipleClassMarker(
+ self.contents[name] = _MultipleClassMarker(
[cls], on_remove=lambda: self._remove_item(name)
)
if compiler is None:
# this is the legacy / testing only ORM _compile_state() use case.
# there is no need to apply criteria options for this.
- self.global_attributes = ga = {}
+ self.global_attributes = {}
assert toplevel
return
else:
"selectable/table as join target"
)
- of_type = None
-
if isinstance(onclause, interfaces.PropComparator):
# descriptor/property given (or determined); this tells us
# explicitly what the expected "left" side of the join is.
or isinstance(attr_value, _MappedAttribute)
)
)
- else:
- is_dataclass_field = False
is_dataclass_field = False
extracted = _extract_mapped_subtype(
# so that prop_has_changes() returns True
for state in states:
if self._pks_changed(uowcommit, state):
- history = uowcommit.get_attribute_history(
+ uowcommit.get_attribute_history(
state, self.key, attributes.PASSIVE_OFF
)
)
if sqltype._isnull and not self.column.foreign_keys:
- new_sqltype = None
-
checks: List[Any]
if our_type_is_pep593:
checks = [our_type, raw_pep_593_type]
extracted_mapped_annotation: Optional[_AnnotationScanType],
is_dataclass_field: bool,
) -> None:
- argument = extracted_mapped_annotation
-
if extracted_mapped_annotation is None:
if self.argument is None:
self._raise_for_required(key, cls)
) -> None:
"""Check the foreign key columns collected and emit error
messages."""
-
- can_sync = False
-
foreign_cols = self._gather_columns_with_annotation(
join_condition, "foreign"
)
else:
key_is_persistent = True
- if key in self.identity_map:
- try:
- merged = self.identity_map[key]
- except KeyError:
- # object was GC'ed right as we checked for it
- merged = None
- else:
- merged = None
+ merged = self.identity_map.get(key)
if merged is None:
if key_is_persistent and key in _resolve_conflict_map:
alternate_effective_path = path._truncate_recursive()
extra_options = (new_opt,)
else:
- new_opt = None
alternate_effective_path = path
extra_options = ()
path = path[self.parent_property]
- with_polymorphic = None
-
user_defined_adapter = (
self._init_user_defined_eager_proc(
loadopt, compile_state, compile_state.attributes
"""
path = self.path
- ezero = None
for ent in mapper_entities:
ezero = ent.entity_zero
if ezero and orm_util._entity_corresponds_to(