Skip to content

Commit

Permalink
[bugfix] Move circular imports to TYPE_CHECKING blocks (backport #5586
Browse files Browse the repository at this point in the history
) (#5647)

[bugfix] Move circular imports to `TYPE_CHECKING` blocks (#5586)

* [bugfix] Move circular imports to TYPE_CHECKING blocks

* Update

(cherry picked from commit d7a30a1)

Co-authored-by: Hailin Wang <[email protected]>
  • Loading branch information
mergify[bot] and haiiliin authored Jul 3, 2024
1 parent f63af10 commit 864e3de
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 22 deletions.
7 changes: 4 additions & 3 deletions src/abaqus/Adaptivity/RuleResult.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations

from abqpy.decorators import abaqus_class_doc, abaqus_method_doc
from typing import TYPE_CHECKING

from abqpy.decorators import abaqus_class_doc, abaqus_method_doc

# Prevent circular import
class ErrorIndicatorResult: ...
if TYPE_CHECKING:
from .ErrorIndicatorResult import ErrorIndicatorResult


@abaqus_class_doc
Expand Down
5 changes: 1 addition & 4 deletions src/abaqus/Assembly/AssemblyModel.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from abqpy.decorators import abaqus_class_doc, abaqus_method_doc

from ..Model.ModelBase import ModelBase
from ..UtilityAndView.abaqusConstants import Boolean
from .PartInstance import PartInstance


# Prevent circular import
class ModelBase: ...


@abaqus_class_doc
class AssemblyModel(ModelBase):
"""Abaqus creates a Model object named `Model-1` when a session is started.
Expand Down
7 changes: 4 additions & 3 deletions src/abaqus/Assembly/ModelInstance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from abqpy.decorators import abaqus_class_doc, abaqus_method_doc

from ..BasicGeometry.EdgeArray import EdgeArray
Expand All @@ -12,9 +14,8 @@
from ..Region.Surface import Surface
from ..UtilityAndView.abaqusConstants import OFF, Boolean


# prevent circular imports
class Model: ...
if TYPE_CHECKING:
from ..Model.Model import Model


@abaqus_class_doc
Expand Down
11 changes: 7 additions & 4 deletions src/abaqus/Connector/ConnectorBehaviorOption.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from typing_extensions import Literal

from abqpy.decorators import abaqus_class_doc, abaqus_method_doc
Expand All @@ -19,9 +21,8 @@
from .ConnectorPotentialArray import ConnectorPotentialArray
from .TangentialBehavior import TangentialBehavior


# Prevent circular import
class DerivedComponent: ...
if TYPE_CHECKING:
from .DerivedComponent import DerivedComponent


@abaqus_class_doc
Expand All @@ -43,7 +44,7 @@ class ConnectorBehaviorOption:
connectorPotentials: ConnectorPotentialArray = []

#: A DerivedComponent object.
derivedComponent: DerivedComponent = DerivedComponent()
derivedComponent: DerivedComponent

#: A ConnectorPotentialArray object.
evolutionPotentials: ConnectorPotentialArray = []
Expand Down Expand Up @@ -164,6 +165,8 @@ def DerivedComponent(self) -> DerivedComponent:
------
ValueError and TextError
"""
from .DerivedComponent import DerivedComponent

self.derivedComponent = derivedComponent = DerivedComponent()
return derivedComponent

Expand Down
11 changes: 9 additions & 2 deletions src/abaqus/Model/ModelBase.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from typing_extensions import Literal

from abqpy.decorators import abaqus_class_doc, abaqus_method_doc
Expand All @@ -8,7 +10,6 @@
from ..Adaptivity.AdaptiveMeshControl import AdaptiveMeshControl
from ..Adaptivity.RemeshingRule import RemeshingRule
from ..Amplitude.Amplitude import Amplitude
from ..Assembly.Assembly import Assembly
from ..BeamSectionProfile.Profile import Profile
from ..BoundaryCondition.BoundaryCondition import BoundaryCondition
from ..Calibration.Calibration import Calibration
Expand Down Expand Up @@ -51,6 +52,9 @@
from ..UtilityAndView.abaqusConstants import abaqusConstants as C
from .KeywordBlock import KeywordBlock

if TYPE_CHECKING:
from ..Assembly.Assembly import Assembly


@abaqus_class_doc
class ModelBase:
Expand Down Expand Up @@ -130,7 +134,7 @@ class ModelBase:
keywordBlock: KeywordBlock = KeywordBlock()

#: An Assembly object.
rootAssembly: Assembly = Assembly()
rootAssembly: Assembly

#: A repository of Amplitude objects.
amplitudes: dict[str, Amplitude] = {}
Expand Down Expand Up @@ -283,7 +287,10 @@ def __init__(
Model
A Model object.
"""
from ..Assembly.Assembly import Assembly

self.steps["Initial"] = InitialStep()
self.rootAssembly = Assembly()

@abaqus_method_doc
def ModelFromInputFile(self, name: str, inputFileName: str):
Expand Down
10 changes: 4 additions & 6 deletions src/abaqus/Part/PartBase.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from __future__ import annotations

from typing import Sequence, overload
from typing import TYPE_CHECKING, Sequence, overload

from typing_extensions import Literal

# prevent circular imports
from abqpy.decorators import abaqus_class_doc, abaqus_method_doc
from abqpy.decorators import abaqus_method_doc

from ..BasicGeometry.Cell import Cell
from ..BasicGeometry.CellArray import CellArray
Expand Down Expand Up @@ -53,9 +52,8 @@
from .AcisFile import AcisFile
from .PartFeature import PartFeature


@abaqus_class_doc
class PartInstance: ...
if TYPE_CHECKING:
from ..Assembly.PartInstance import PartInstance


class PartBase(PartFeature):
Expand Down

0 comments on commit 864e3de

Please sign in to comment.