Skip to content

Commit

Permalink
Fix some type hint errors (backport #5816) (#5822)
Browse files Browse the repository at this point in the history
Co-authored-by: huibosa <[email protected]>
  • Loading branch information
mergify[bot] and huibosa authored Sep 30, 2024
1 parent ce6b8de commit f8840c2
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 48 deletions.
9 changes: 6 additions & 3 deletions src/abaqus/Amplitude/AmplitudeModel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Sequence, Union
from typing import TYPE_CHECKING, Sequence, Union

from typing_extensions import Literal

Expand Down Expand Up @@ -29,6 +29,9 @@
from .SpectrumAmplitude import SpectrumAmplitude
from .TabularAmplitude import TabularAmplitude

if TYPE_CHECKING:
from numpy.typing import NDArray


@abaqus_class_doc
class AmplitudeModel(ModelBase):
Expand Down Expand Up @@ -231,7 +234,7 @@ def PeriodicAmplitude(
frequency: float,
start: float,
a_0: float,
data: tuple,
data: tuple | NDArray,
timeSpan: Literal[C.STEP, C.TOTAL] = STEP,
) -> PeriodicAmplitude:
"""This method creates a PeriodicAmplitude object.
Expand Down Expand Up @@ -521,7 +524,7 @@ def SpectrumAmplitude(
def TabularAmplitude(
self,
name: str,
data: Sequence[Sequence[float]],
data: Sequence[Sequence[float]] | NDArray,
smooth: Union[Literal[C.SOLVER_DEFAULT], float] = SOLVER_DEFAULT,
timeSpan: Literal[C.STEP, C.TOTAL] = STEP,
) -> TabularAmplitude:
Expand Down
10 changes: 5 additions & 5 deletions src/abaqus/Constraint/ConstraintModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,11 @@ def MultipointConstraint(
def RigidBody(
self,
name: str,
refPointRegion: Region,
bodyRegion: str | None = None,
tieRegion: str | None = None,
pinRegion: str | None = None,
surfaceRegion: str | None = None,
refPointRegion: Region | None,
bodyRegion: Region | None = None,
tieRegion: Region | None = None,
pinRegion: Region | None = None,
surfaceRegion: Region | None = None,
refPointAtCOM: Boolean = OFF,
isothermal: Boolean = OFF,
) -> RigidBody:
Expand Down
66 changes: 32 additions & 34 deletions src/abaqus/Feature/Feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
from ..BasicGeometry.ReferencePoint import ReferencePoint as ReferencePointType
from ..BasicGeometry.Transform import Transform
from ..Datum.Datum import Datum
from ..Datum.DatumAxis import DatumAxis
from ..Datum.DatumPlane import DatumPlane
from ..Datum.DatumPoint import DatumPoint
from ..Mesh.MeshEdge import MeshEdge
from ..Mesh.MeshFace import MeshFace
Expand Down Expand Up @@ -406,7 +404,7 @@ def DatumAxisByCylFace(
@abaqus_method_doc
def DatumAxisByNormalToPlane(
self,
plane: Face | MeshFace | DatumPlane,
plane: Face | MeshFace | Datum,
point: ConstrainedSketchVertex | DatumPoint | MeshNode | InterestingPoint | Sequence[float] | NDArray,
) -> Feature:
"""This method creates a Feature object and a DatumAxis object normal to the specified plane and passing
Expand Down Expand Up @@ -439,7 +437,7 @@ def DatumAxisByNormalToPlane(
@abaqus_method_doc
def DatumAxisByParToEdge(
self,
edge: Edge | MeshEdge | DatumAxis,
edge: Edge | MeshEdge | Datum,
point: ConstrainedSketchVertex | DatumPoint | MeshNode | InterestingPoint | Sequence[float] | NDArray,
) -> Feature:
"""This method creates a Feature object and a DatumAxis object parallel to the specified edge and
Expand Down Expand Up @@ -500,8 +498,8 @@ def DatumAxisByPrincipalAxis(self, principalAxis: Literal[C.XAXIS, C.YAXIS, C.ZA
@abaqus_method_doc
def DatumAxisByRotation(
self,
line: Edge | DatumAxis | MeshEdge,
axis: Edge | DatumAxis | MeshEdge,
line: Edge | Datum | MeshEdge,
axis: Edge | Datum | MeshEdge,
angle: float,
) -> Feature:
"""This method creates a Feature object and a DatumAxis object in a three-dimensional model by rotating
Expand Down Expand Up @@ -539,7 +537,7 @@ def DatumAxisByRotation(
@abaqus_method_doc
def DatumAxisByRotation(
self,
line: Edge | DatumAxis | MeshEdge,
line: Edge | Datum | MeshEdge,
point: ConstrainedSketchVertex | DatumPoint | MeshNode | InterestingPoint | Sequence[float] | NDArray,
angle: float,
) -> Feature:
Expand Down Expand Up @@ -645,8 +643,8 @@ def DatumAxisByThruEdge(self, edge: Edge | MeshEdge) -> Feature:
@abaqus_method_doc
def DatumAxisByTwoPlane(
self,
plane1: Face | MeshFace | DatumPlane,
plane2: Face | MeshFace | DatumPlane,
plane1: Face | MeshFace | Datum,
plane2: Face | MeshFace | Datum,
) -> Feature:
"""This method creates a Feature object and a DatumAxis object at the intersection of two planes.
Expand Down Expand Up @@ -795,8 +793,8 @@ def DatumCsysByThreePoints(
origin: ConstrainedSketchVertex | DatumPoint | MeshNode | InterestingPoint | Sequence[float] | NDArray,
point1: ConstrainedSketchVertex | DatumPoint | MeshNode | InterestingPoint | Sequence[float] | NDArray,
point2: ConstrainedSketchVertex | DatumPoint | MeshNode | InterestingPoint | Sequence[float] | NDArray,
line1: Edge | DatumAxis | MeshEdge,
line2: Edge | DatumAxis | MeshEdge,
line1: Edge | Datum | MeshEdge,
line2: Edge | Datum | MeshEdge,
name: str = "",
) -> Feature:
"""This method creates a Feature object and a DatumCsys object from three points.
Expand Down Expand Up @@ -849,8 +847,8 @@ def DatumCsysByThreePoints(
def DatumCsysByTwoLines(
self,
coordSysType: Literal[C.CARTESIAN, C.CYLINDRICAL, C.SPHERICAL],
line1: Edge | MeshEdge | DatumAxis,
line2: Edge | MeshEdge | DatumAxis,
line1: Edge | MeshEdge | Datum,
line2: Edge | MeshEdge | Datum,
name: str = "",
) -> Feature:
"""This method creates a Feature object and a DatumCsys object from two orthogonal lines. The origin of
Expand Down Expand Up @@ -923,7 +921,7 @@ def DatumPlaneByPrincipalPlane(
@abaqus_method_doc
def DatumPlaneByOffset(
self,
plane: Face | MeshFace | DatumPlane,
plane: Face | MeshFace | Datum,
flip: Literal[C.SIDE1, C.SIDE2],
offset: float,
) -> Feature:
Expand Down Expand Up @@ -961,7 +959,7 @@ def DatumPlaneByOffset(
@abaqus_method_doc
def DatumPlaneByOffset(
self,
plane: Face | MeshFace | DatumPlane,
plane: Face | MeshFace | Datum,
point: ConstrainedSketchVertex | DatumPoint | MeshNode | InterestingPoint | Sequence[float] | NDArray,
) -> Feature:
"""This method creates a Feature object and a DatumPlane object offset from an existing plane and
Expand Down Expand Up @@ -997,8 +995,8 @@ def DatumPlaneByOffset(self, *args, **kwargs) -> Feature:

def DatumPlaneByRotation(
self,
plane: Face | MeshFace | DatumPlane,
axis: Edge | MeshEdge | DatumAxis,
plane: Face | MeshFace | Datum,
axis: Edge | MeshEdge | Datum,
angle: float,
) -> Feature:
"""This method creates a Feature object and a DatumPlane object by rotating a plane about the specified
Expand Down Expand Up @@ -1068,7 +1066,7 @@ def DatumPlaneByThreePoints(
@abaqus_method_doc
def DatumPlaneByLinePoint(
self,
line: Edge | DatumAxis | MeshEdge,
line: Edge | Datum | MeshEdge,
point: ConstrainedSketchVertex | DatumPoint | MeshNode | InterestingPoint | Sequence[float] | NDArray,
) -> Feature:
"""This method creates a Feature object and a DatumPlane object that pass through the specified line and
Expand Down Expand Up @@ -1102,7 +1100,7 @@ def DatumPlaneByLinePoint(
def DatumPlaneByPointNormal(
self,
point: ConstrainedSketchVertex | DatumPoint | MeshNode | InterestingPoint | Sequence[float] | NDArray,
normal: Edge | MeshEdge | DatumAxis,
normal: Edge | MeshEdge | Datum,
) -> Feature:
"""This method creates a Feature object and a DatumPlane object normal to the specified line and running
through the specified point.
Expand Down Expand Up @@ -1248,10 +1246,10 @@ def DatumPointByMidPoint(
@abaqus_method_doc
def DatumPointByOnFace(
self,
face: Face | DatumPlane,
edge1: Edge | DatumAxis,
face: Face | Datum,
edge1: Edge | Datum,
offset1: float,
edge2: Edge | DatumAxis,
edge2: Edge | Datum,
offset2: float,
) -> Feature:
"""This method creates a Feature object and a DatumPoint object on the specified face, offset from two
Expand Down Expand Up @@ -1322,7 +1320,7 @@ def DatumPointByEdgeParam(self, edge: Edge, parameter: float) -> Feature:
def DatumPointByProjOnEdge(
self,
point: ConstrainedSketchVertex | DatumPoint | MeshNode | InterestingPoint | Sequence[float] | NDArray,
edge: Edge | MeshEdge | DatumAxis,
edge: Edge | MeshEdge | Datum,
) -> Feature:
"""This method creates a Feature object and a DatumPoint object along an edge by projecting an existing
point along the normal to the edge.
Expand Down Expand Up @@ -1355,7 +1353,7 @@ def DatumPointByProjOnEdge(
def DatumPointByProjOnFace(
self,
point: ConstrainedSketchVertex | DatumPoint | MeshNode | InterestingPoint | Sequence[float] | NDArray,
face: Face | DatumPlane,
face: Face | Datum,
) -> Feature:
"""This method creates a Feature object and a DatumPoint object on a specified face by projecting an
existing point onto the face.
Expand Down Expand Up @@ -1388,11 +1386,11 @@ def DatumPointByProjOnFace(
@abaqus_method_doc
def MakeSketchTransform(
self,
sketchPlane: DatumPlane | Face,
sketchPlane: Datum | Face,
origin: tuple = (),
sketchOrientation: Literal[C.RIGHT, C.LEFT, C.TOP, C.BOTTOM] = RIGHT,
sketchPlaneSide: Literal[C.SIDE1, C.SIDE2] = SIDE1,
sketchUpEdge: Edge | DatumAxis | None = None,
sketchUpEdge: Edge | Datum | None = None,
) -> Transform:
"""This method creates a Transform object. A Transform object is a 4x3 matrix of Floats that represents
the transformation from sketch coordinates to part coordinates.
Expand Down Expand Up @@ -1435,7 +1433,7 @@ def MakeSketchTransform(
return Transform()

@abaqus_method_doc
def PartitionCellByDatumPlane(self, cells: Sequence[Cell], datumPlane: DatumPlane) -> Feature:
def PartitionCellByDatumPlane(self, cells: Sequence[Cell], datumPlane: Datum) -> Feature:
"""This method partitions one or more cells using the given datum plane.
.. note::
Expand Down Expand Up @@ -1496,7 +1494,7 @@ def PartitionCellByExtrudeEdge(
self,
cells: Sequence[Cell],
edges: Edge,
line: Edge | DatumAxis,
line: Edge | Datum,
sense: Literal[C.FORWARD, C.REVERSE],
) -> Feature:
"""This method partitions one or more cells by extruding selected edges in the given direction.
Expand Down Expand Up @@ -1639,7 +1637,7 @@ def PartitionCellByPlanePointNormal(
self,
cells: Sequence[Cell],
point: ConstrainedSketchVertex | InterestingPoint | DatumPoint,
normal: Edge | DatumAxis,
normal: Edge | Datum,
) -> Feature:
"""This method partitions one or more cells using a plane defined by a point and a normal direction.
Expand Down Expand Up @@ -1742,7 +1740,7 @@ def PartitionCellBySweepEdge(self, cells: Sequence[Cell], edges: Sequence[Edge],
return Feature()

@abaqus_method_doc
def PartitionEdgeByDatumPlane(self, edges: Sequence[Edge], datumPlane: DatumPlane) -> Feature:
def PartitionEdgeByDatumPlane(self, edges: Sequence[Edge], datumPlane: Datum) -> Feature:
"""This method partitions an edge where it intersects with a datum plane.
.. note::
Expand Down Expand Up @@ -1935,7 +1933,7 @@ def PartitionFaceByCurvedPathEdgePoints(
return Feature()

@abaqus_method_doc
def PartitionFaceByDatumPlane(self, faces: Sequence[Face], datumPlane: DatumPlane) -> Feature:
def PartitionFaceByDatumPlane(self, faces: Sequence[Face], datumPlane: Datum) -> Feature:
"""This method partitions one or more faces using the given datum plane.
.. note::
Expand Down Expand Up @@ -2123,7 +2121,7 @@ def PartitionFaceBySketch(
def PartitionFaceBySketchDistance(
self,
faces: Sequence[Face],
sketchPlane: Face | DatumPlane,
sketchPlane: Face | Datum,
sketchPlaneSide: Literal[C.SIDE1, C.SIDE2],
sketchUpEdge: Edge,
sketch: ConstrainedSketch,
Expand Down Expand Up @@ -2174,7 +2172,7 @@ def PartitionFaceBySketchDistance(
def PartitionFaceBySketchRefPoint(
self,
faces: Sequence[Face],
sketchPlane: Face | DatumPlane,
sketchPlane: Face | Datum,
sketchUpEdge: Edge,
sketch: ConstrainedSketch,
point: ConstrainedSketchVertex | DatumPoint | InterestingPoint | Sequence[float] | NDArray,
Expand Down Expand Up @@ -2222,7 +2220,7 @@ def PartitionFaceBySketchRefPoint(
def PartitionFaceBySketchThruAll(
self,
faces: Sequence[Face],
sketchPlane: str,
sketchPlane: Face | Datum,
sketchPlaneSide: Literal[C.SIDE1, C.SIDE2],
sketchUpEdge: str,
sketch: ConstrainedSketch,
Expand Down
4 changes: 2 additions & 2 deletions src/abaqus/Region/Region.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Sequence, Union, overload
from typing import Sequence, Union, ValuesView, overload

from abqpy.decorators import abaqus_class_doc, abaqus_method_doc

Expand Down Expand Up @@ -65,7 +65,7 @@ def __init__(
edges: Sequence[Edge] | None = None,
faces: Sequence[Face] | None = None,
cells: Sequence[Cell] | None = None,
referencePoints: Sequence[ReferencePoint] = (),
referencePoints: Sequence[ReferencePoint] | ValuesView[ReferencePoint] | None = None,
xVertices: Sequence[Vertex] | None = None,
xEdges: Sequence[Vertex] | None = None,
xFaces: Sequence[Vertex] | None = None,
Expand Down
4 changes: 2 additions & 2 deletions src/abaqus/Region/RegionPart.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Sequence, Union, overload
from typing import Sequence, Union, ValuesView, overload

from typing_extensions import Literal

Expand Down Expand Up @@ -208,7 +208,7 @@ def Set(
xVertices: Sequence[Vertex] | None = None,
xEdges: Sequence[Edge] | None = None,
xFaces: Sequence[Face] | None = None,
referencePoints: Sequence[ReferencePoint] = (),
referencePoints: Sequence[ReferencePoint] | ValuesView[ReferencePoint] | None = None,
skinFaces: tuple[tuple[str, Sequence[Face]], ...] = ...,
skinEdges: tuple[tuple[str, Sequence[Edge]], ...] = ...,
stringerEdges: tuple[tuple[str, Sequence[Edge]], ...] = ...,
Expand Down
7 changes: 6 additions & 1 deletion src/abaqus/Sketcher/SketchModel.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from abqpy.decorators import abaqus_class_doc, abaqus_method_doc

from ..Model.ModelBase import ModelBase
from .ConstrainedSketch import ConstrainedSketch

if TYPE_CHECKING:
from numpy.typing import NDArray


@abaqus_class_doc
class SketchModel(ModelBase):
Expand All @@ -22,7 +27,7 @@ def ConstrainedSketch(
name: str,
sheetSize: float,
gridSpacing: float | None = None,
transform: tuple = (),
transform: tuple | NDArray = (),
) -> ConstrainedSketch:
"""This method creates a ConstrainedSketch object. If the sketch cannot be created, the method returns
None.
Expand Down
2 changes: 1 addition & 1 deletion src/abaqus/Step/StepModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ def ExplicitDynamicsStep(
] = AUTOMATIC_GLOBAL,
maxIncrement: float | None = None,
scaleFactor: float = 1,
massScaling: Union[MassScalingArray, Literal[C.PREVIOUS_STEP]] = PREVIOUS_STEP,
massScaling: Union[MassScalingArray, Literal[C.PREVIOUS_STEP]] | tuple = PREVIOUS_STEP,
linearBulkViscosity: float = 0,
quadBulkViscosity: float = 1,
userDefinedInc: float | None = None,
Expand Down

0 comments on commit f8840c2

Please sign in to comment.