Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDoyle2 committed Oct 14, 2024
1 parent 2f70dd1 commit f576688
Show file tree
Hide file tree
Showing 64 changed files with 167 additions and 147 deletions.
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf_interface/get_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from __future__ import annotations
from copy import deepcopy
from collections import defaultdict
from typing import Union, Optional, Any, TYPE_CHECKING
from typing import Optional, Any, TYPE_CHECKING

import numpy as np

Expand Down
8 changes: 4 additions & 4 deletions pyNastran/bdf/bdf_interface/get_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@ def Materials(self, mids, msg='') -> list[Material]:
# LOADS

def Load(self, sid: int, consider_load_combinations: bool=True,
msg: str='') -> list[Union[LOAD, GRAV, ACCEL, ACCEL1, SLOAD,
FORCE, FORCE1, FORCE2,
MOMENT, MOMENT1, MOMENT2,
PLOAD, PLOAD1, PLOAD2, PLOAD4]]:
msg: str='') -> list[LOAD | GRAV | ACCEL | ACCEL1 | SLOAD |
FORCE | FORCE1 | FORCE2 |
MOMENT | MOMENT1 | MOMENT2 |
PLOAD | PLOAD1 | PLOAD2 | PLOAD4]:
"""
Gets an LOAD or FORCE/PLOAD4/etc.
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf_interface/pybdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from io import StringIO
from itertools import count
from collections import defaultdict
from typing import Optional, Union, Any, cast
from typing import Optional, Any, cast

import numpy as np
from cpylog import get_logger2, SimpleLogger
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf_interface/stats.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations
from typing import Any, Union, TYPE_CHECKING
from typing import Any, TYPE_CHECKING
if TYPE_CHECKING: # pragma: no cover
from pyNastran.bdf.bdf import BDF

Expand Down
4 changes: 2 additions & 2 deletions pyNastran/bdf/bdf_interface/subcase/cards.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, Any
from typing import Any
from pyNastran.utils.numpy_utils import bytes_type
from .subcase_base import CaseControlCard

Expand Down Expand Up @@ -235,7 +235,7 @@ class CheckCard(CaseControlCard):
allowed_keys: set[str] = set([])

# key:(type, allowed_values)
allowed_values: dict[str, Union[float, str]] = {}
allowed_values: dict[str, float | str] = {}

# the allowed value for the key, options, value approach
allowed_strings: set[str] = set([])
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf_interface/subcase/cards_check.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, Any
from typing import Any
from .cards import CheckCard


Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf_interface/subcase/matrix.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union, Any
from typing import Any
from pyNastran.utils.numpy_utils import integer_types

class RealMatrixCard:
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf_interface/subcase/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- write_stress_type(key, options, value, spaces='')
"""
from typing import Optional, Union, Any
from typing import Optional, Any
from pyNastran.utils.numpy_utils import integer_types
from pyNastran.bdf.cards.collpase_card import collapse_thru_packs

Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf_interface/write_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sys
from io import IOBase
from pathlib import PurePath
from typing import Union, Optional, Any, cast, TYPE_CHECKING
from typing import Optional, Any, cast, TYPE_CHECKING

from pyNastran.bdf.field_writer_8 import print_card_8
from pyNastran.bdf.field_writer_16 import print_card_16
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf_interface/write_mesh_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import annotations
import os
from collections import defaultdict
from typing import Union, Optional, Any, TYPE_CHECKING
from typing import Optional, Any, TYPE_CHECKING

import numpy as np
from pyNastran.bdf.field_writer_8 import print_card_8
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/cards/elements/beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
from __future__ import annotations
from typing import Union, Any, TYPE_CHECKING
from typing import Any, TYPE_CHECKING

import numpy as np
from numpy.linalg import norm # type: ignore
Expand Down
1 change: 0 additions & 1 deletion pyNastran/bdf/cards/elements/beam_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
- DBOX (will be a shear center issue)
"""
from typing import Union
import numpy as np
from pyNastran.nptyping_interface import NDArray3float, NDArray33float, NDArrayN3float
from pyNastran.bdf.cards.aero.utils import elements_from_quad, tri_cap
Expand Down
4 changes: 2 additions & 2 deletions pyNastran/bdf/cards/elements/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"""
from __future__ import annotations
from typing import Union, Optional, Any, TYPE_CHECKING
from typing import Optional, Any, TYPE_CHECKING

import numpy as np
from numpy import cross, allclose
Expand Down Expand Up @@ -4892,7 +4892,7 @@ def Area(self) -> float:
return area

@property
def node_ids(self) -> list[Union[int, None]]:
def node_ids(self) -> list[int | None]:
return self._node_ids(nodes=self.nodes_ref, allow_empty_nodes=True)

def raw_fields(self):
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/cards/elements/solid.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""
from __future__ import annotations
from typing import Union, Any, TYPE_CHECKING
from typing import Any, TYPE_CHECKING
import numpy as np
from numpy import dot, cross
from numpy.linalg import norm # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/cards/loads/dloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""
from __future__ import annotations
import warnings
from typing import Union, Optional, TYPE_CHECKING
from typing import Optional, TYPE_CHECKING
import numpy as np

from pyNastran.utils.numpy_utils import integer_types
Expand Down
8 changes: 4 additions & 4 deletions pyNastran/bdf/cards/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"""
from __future__ import annotations
from itertools import count
from typing import Union, Optional, Any, TYPE_CHECKING
from typing import Optional, Any, TYPE_CHECKING
import numpy as np

from pyNastran.utils.numpy_utils import integer_types
Expand Down Expand Up @@ -1098,7 +1098,7 @@ def export_to_hdf5(cls, h5_file, model, nids):
h5_file.create_dataset('ps', data=ps)
h5_file.create_dataset('seid', data=seid)

def __init__(self, nid: int, xyz: Union[None, list[float], np.ndarray],
def __init__(self, nid: int, xyz: np.ndarray | list[float],
cp: int=0, cd: int=0, ps: str='', seid: int=0,
comment: str='') -> None:
"""
Expand Down Expand Up @@ -1671,7 +1671,7 @@ def _init_from_empty(cls):
return POINT(nid, xyz, cp=0, comment='')

def __init__(self, nid: int,
xyz: Union[list[float], np.ndarray],
xyz: np.ndarray | list[float],
cp: int=0, comment: str='') -> None:
"""
Creates the POINT card
Expand Down Expand Up @@ -1843,7 +1843,7 @@ def uncross_reference(self) -> None:
"""Removes cross-reference links"""
self.cp_ref = self.Cp()

def raw_fields(self) -> list[Union[str, int, float, None]]:
def raw_fields(self) -> list[str | int | float | None]:
"""
Gets the fields in their unmodified form
Expand Down
1 change: 0 additions & 1 deletion pyNastran/bdf/cards/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from pyNastran.bdf.field_writer_8 import print_card_8
from pyNastran.bdf.field_writer_16 import print_card_16
from pyNastran.utils.numpy_utils import integer_types, float_types
from typing import Union

#float_words_1 = [
#b'K6ROT', b'WTMASS', b'SNORM', b'PATVER', b'MAXRATIO', b'EPSHT',
Expand Down
7 changes: 4 additions & 3 deletions pyNastran/bdf/cards/properties/bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""
from __future__ import annotations
from itertools import count
from typing import Union, Any, TYPE_CHECKING
from typing import Any, TYPE_CHECKING
from numpy import pi, array
import numpy as np

Expand Down Expand Up @@ -3202,7 +3202,7 @@ def MassPerLength(self) -> float:
assert isinstance(self.A, float), self.get_stats()
return self.A * rho + self.nsm

def raw_fields(self) -> list[Union[str, float, int, None]]:
def raw_fields(self) -> list[str | float | int | None]:
return self.repr_fields()

def repr_fields(self):
Expand Down Expand Up @@ -3237,7 +3237,8 @@ def write_card(self, size: int=8, is_double: bool=False) -> str:


def split_arbitrary_thickness_section(key: str,
value: Union[str, float, list[int]]) -> tuple[int, Union[float, list[int]]]:
value: str | float | list[int],
) -> tuple[int, float | list[int]]:
"""
Helper method for PBRSECT/PBMSECT
Expand Down
6 changes: 3 additions & 3 deletions pyNastran/bdf/cards/properties/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import copy
from itertools import count, zip_longest
import warnings
from typing import Union, Optional, Any, TYPE_CHECKING
from typing import Optional, Any, TYPE_CHECKING
import numpy as np

from pyNastran.utils.numpy_utils import integer_types, float_types, zip_strict
Expand Down Expand Up @@ -377,7 +377,7 @@ def Mid(self, iply: int) -> int:
mid = self.mids[iply]
return mid

def Material(self, iply: int) -> Union[MAT1, MAT8, MAT9]:
def Material(self, iply: int) -> MAT1 | MAT8 | MAT9:
"""
Gets the material of the :math:`i^{th}` ply (not the ID unless
it is not cross-referenced).
Expand Down Expand Up @@ -1250,7 +1250,7 @@ def get_Ainv_equivalent_pshell(self,
return Ex, Ey, Gxy, nu_xy

def get_Qbar_matrix(self,
mid_ref: Union[MAT1, MAT8],
mid_ref: MAT1 | MAT8,
theta: float=0.) -> np.ndarray:
"""theta must be in radians"""
assert isinstance(theta, float_types), theta
Expand Down
8 changes: 4 additions & 4 deletions pyNastran/bdf/mesh_utils/bdf_equivalence.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def bdf_equivalence_nodes(bdf_filename: str,
model2.read_bdf(bdf_filename_out)
return model

#def _simplify_node_set_old(node_set: Optional[Union[list[int], list[NDArrayNint]]],
#def _simplify_node_set_old(node_set: Optional[list[int] | list[NDArrayNint]]
#idtype: str='int32') -> Optional[list[NDArrayNint]]:
#if node_set is None:
#return
Expand All @@ -141,9 +141,9 @@ def bdf_equivalence_nodes(bdf_filename: str,
# list of ndarrays
#return node_set

def _simplify_node_set(node_set: Optional[Union[list[int],
set[int],
list[NDArrayNint]]],
def _simplify_node_set(node_set: Optional[list[int] |
set[int] |
list[NDArrayNint]],
idtype: str='int32') -> Optional[list[NDArrayNint]]: # pragma: no cover
"""
accepts multiple forms of the node_set parameter
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/mesh_utils/bdf_renumber.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"""
from itertools import chain
from io import StringIO, IOBase
from typing import Optional, Union
from typing import Optional

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/mesh_utils/cleanup_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from copy import deepcopy
from typing import Union, Any
from typing import Any
from pyNastran.bdf.bdf import BDF, LOAD, PLOAD2, PLOAD4


Expand Down
3 changes: 2 additions & 1 deletion pyNastran/bdf/mesh_utils/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,8 @@ def _convert_dconstr(model: BDF, dconstr: DCONSTR, pressure_scale: float) -> Non
print(msg)
raise NotImplementedError(msg)

def _convert_dvcrel1(dvcrel: Union[DVCREL1, DVCREL2], xyz_scale: float, mass_scale: float) -> float:
def _convert_dvcrel1(dvcrel: DVCREL1 | DVCREL2,
xyz_scale: float, mass_scale: float) -> float:
"""helper for ``_convert_optimization``"""
element_type = dvcrel.element_type
if element_type == 'CBUSH':
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/mesh_utils/export_mcids.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def _export_coord_axes(nodes, bars, csv_filename: str):
out_file.write('BAR,%i,%i,%i\n' % bari)

def _rotate_mcid(elem: ShellElement,
pid_ref: Union[PCOMP, PCOMPG, PSHELL], iply: int,
pid_ref: PCOMP | PCOMPG | PSHELL, iply: int,
imat: np.ndarray, jmat: np.ndarray, normal: np.ndarray,
consider_property_rotation: bool=True) -> tuple[np.ndarray, np.ndarray]:
"""
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/mesh_utils/find_coplanar_elements.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations
from typing import Union, Optional, TYPE_CHECKING
from typing import Optional, TYPE_CHECKING

import numpy as np
from pyNastran.bdf.mesh_utils.internal_utils import get_bdf_model
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/mesh_utils/force_to_pressure.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections import defaultdict
from typing import Union, Optional
from typing import Optional

import numpy as np
from pyNastran.bdf.bdf import read_bdf, BDF, FORCE, PLOAD4
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/mesh_utils/pierce_shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- pierce_shell_model(bdf_filename, xyz_points, tol=1.0)
"""
from itertools import count
from typing import Optional, Union, Any
from typing import Optional, Any
import numpy as np
from pyNastran.bdf.bdf import BDF, read_bdf
from pyNastran.bdf.mesh_utils.bdf_equivalence import _get_tree
Expand Down
Loading

0 comments on commit f576688

Please sign in to comment.