Skip to content

Commit e4a17ea

Browse files
committed
typing
1 parent e15ff97 commit e4a17ea

File tree

13 files changed

+58
-68
lines changed

13 files changed

+58
-68
lines changed

pyNastran/bdf/bdf_interface/add_card.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,9 @@
752752

753753
class AddCoords:
754754
def add_cord2r(self, cid: int,
755-
origin: Optional[Union[list[float], NDArray3float]],
756-
zaxis: Optional[Union[list[float], NDArray3float]],
757-
xzplane: Optional[Union[list[float], NDArray3float]],
755+
origin: Optional[list[float] | NDArray3float],
756+
zaxis: Optional[list[float] | NDArray3float],
757+
xzplane: Optional[list[float] | NDArray3float],
758758
rid: int=0, setup: bool=True, comment: str='') -> CORD2R:
759759
"""
760760
Creates the CORD2R card, which defines a rectangular coordinate
@@ -782,9 +782,9 @@ def add_cord2r(self, cid: int,
782782
return coord
783783

784784
def add_cord2c(self, cid: int,
785-
origin: Optional[Union[list[float], NDArray3float]],
786-
zaxis: Optional[Union[list[float], NDArray3float]],
787-
xzplane: Optional[Union[list[float], NDArray3float]],
785+
origin: Optional[list[float] | NDArray3float],
786+
zaxis: Optional[list[float] | NDArray3float],
787+
xzplane: Optional[list[float] | NDArray3float],
788788
rid: int=0, setup: bool=True, comment: str='') -> CORD2C:
789789
"""
790790
Creates the CORD2C card, which defines a cylindrical coordinate
@@ -812,9 +812,9 @@ def add_cord2c(self, cid: int,
812812
return coord
813813

814814
def add_cord2s(self, cid: int,
815-
origin: Optional[Union[list[float], NDArray3float]],
816-
zaxis: Optional[Union[list[float], NDArray3float]],
817-
xzplane: Optional[Union[list[float], NDArray3float]],
815+
origin: Optional[list[float] | NDArray3float],
816+
zaxis: Optional[list[float] | NDArray3float],
817+
xzplane: Optional[list[float] | NDArray3float],
818818
rid: int=0, setup: bool=True, comment: str='') -> CORD2S:
819819
"""
820820
Creates the CORD2C card, which defines a spherical coordinate
@@ -2842,7 +2842,7 @@ def add_pcompg(self, pid, global_ply_ids, mids, thicknesses, thetas=None, souts=
28422842

28432843

28442844
class Add3dElements:
2845-
def add_ctetra(self, eid, pid, nids, comment='') -> Union[CTETRA4, CTETRA10]:
2845+
def add_ctetra(self, eid, pid, nids, comment='') -> CTETRA4 | CTETRA10:
28462846
"""
28472847
Creates a CTETRA4/CTETRA10
28482848
@@ -2865,7 +2865,7 @@ def add_ctetra(self, eid, pid, nids, comment='') -> Union[CTETRA4, CTETRA10]:
28652865
self._add_methods._add_element_object(elem)
28662866
return elem
28672867

2868-
def add_cpyram(self, eid, pid, nids, comment='') -> Union[CPYRAM5, CPYRAM13]:
2868+
def add_cpyram(self, eid, pid, nids, comment='') -> CPYRAM5 | CPYRAM13:
28692869
"""
28702870
Creates a CPYRAM5/CPYRAM13
28712871
@@ -5526,7 +5526,7 @@ def add_dresp1(self, dresp_id: int, label: str,
55265526
response_type: str, property_type: str, region: int,
55275527
atta: Optional[int | float | str],
55285528
attb: Optional[int | float | str],
5529-
atti: list[Union[int, float, str]],
5529+
atti: list[int | float | str],
55305530
validate: bool=True, comment: str='') -> DRESP1:
55315531
"""
55325532
Creates a DRESP1 card.
@@ -6434,11 +6434,11 @@ def add_point(self, nid: int, xyz: Any, cp: int=0, comment: str='') -> POINT:
64346434
#self._add_load_object(load)
64356435
#return load
64366436

6437-
def add_param(self, key: str, values: list[Union[int, float, str]],
6437+
def add_param(self, key: str, values: list[int | float | str],
64386438
comment: str='') -> PARAM:
64396439
return self._add_param_nastran(key, values, comment=comment)
64406440

6441-
def _add_param_nastran(self, key: str, values: list[Union[int, float, str]],
6441+
def _add_param_nastran(self, key: str, values: list[int | float | str],
64426442
comment: str='') -> PARAM:
64436443
"""
64446444
Creates a PARAM card
@@ -6478,7 +6478,7 @@ def add_mdlprm(self, mdlprm_dict: dict[str, int | float],
64786478
return mdlprm
64796479

64806480

6481-
def _add_param_mystran(self, key: str, values: list[Union[int, float, str]],
6481+
def _add_param_mystran(self, key: str, values: list[int | float | str],
64826482
comment: str='') -> PARAM_MYSTRAN:
64836483
"""
64846484
Creates a PARAM card
@@ -6497,7 +6497,7 @@ def _add_param_mystran(self, key: str, values: list[Union[int, float, str]],
64976497
self._add_methods._add_param_object(param)
64986498
return param
64996499

6500-
def _add_param_nasa95(self, key: str, values: list[Union[int, float, str]],
6500+
def _add_param_nasa95(self, key: str, values: list[int | float | str],
65016501
comment: str='') -> PARAM_NASA95:
65026502
"""
65036503
Creates a PARAM card

pyNastran/bdf/bdf_interface/add_methods.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ def _add_ringfl_object(self, ringfl: RINGFL, allow_overwrites: bool=False) -> No
273273
self.model._type_to_id_map[ringfl.type].append(key)
274274
self.model._is_axis_symmetric = True
275275

276-
def _add_ringax_object(self, ringax: Union[RINGAX, POINTAX], allow_overwrites: bool=False) -> None:
276+
def _add_ringax_object(self, ringax: RINGAX | POINTAX,
277+
allow_overwrites: bool=False) -> None:
277278
"""adds a RINGAX card"""
278279
key = ringax.nid
279280
model = self.model
@@ -471,7 +472,7 @@ def _add_doptprm_object(self, doptprm: DOPTPRM) -> None:
471472
"""adds a DOPTPRM"""
472473
self.model.doptprm = doptprm
473474

474-
def _add_nsm_object(self, nsm: Union[NSM, NSM1, NSML, NSML1], allow_overwrites: bool=False) -> None:
475+
def _add_nsm_object(self, nsm: NSM | NSM1 | NSML | NSML1, allow_overwrites: bool=False) -> None:
475476
"""adds an nsm object to a nsm set"""
476477
key = nsm.sid
477478
assert key > 0, 'sid=%s must be positive; nsm=\n%s' % (key, nsm)
@@ -491,8 +492,8 @@ def _add_nsmadd_object(self, nsmadd: NSMADD, allow_overwrites: bool=False) -> No
491492
self.model.nsmadds[key] = [nsmadd]
492493
self.model._type_to_id_map[nsmadd.type].append(key)
493494

494-
def _add_mass_object(self, mass: Union[CMASS1, CMASS2, CMASS3, CMASS4,
495-
CONM1, CONM2], allow_overwrites: bool=False) -> None:
495+
def _add_mass_object(self, mass: CMASS1, CMASS2 | CMASS3 | CMASS4 |
496+
CONM1 | CONM2, allow_overwrites: bool=False) -> None:
496497
key = mass.eid
497498
model = self.model
498499
assert key > 0, 'eid=%s must be positive; mass=\n%s' % (key, mass)
@@ -507,9 +508,9 @@ def _add_damper_object(self, elem, allow_overwrites: bool=False) -> None:
507508
""".. warning:: can dampers have the same ID as a standard element?"""
508509
return self._add_element_object(elem, allow_overwrites)
509510

510-
def _add_rigid_element_object(self, elem: Union[RBAR, RBAR1,
511-
RBE1, RBE2, RBE3,
512-
RROD, RSPLINE, RSSCON],
511+
def _add_rigid_element_object(self, elem: RBAR | RBAR1 |
512+
RBE1 | RBE2 | RBE3 |
513+
RROD | RSPLINE | RSSCON,
513514
allow_overwrites: bool=False) -> None:
514515
key = elem.eid
515516
model = self.model
@@ -519,7 +520,7 @@ def _add_rigid_element_object(self, elem: Union[RBAR, RBAR1,
519520
model.rigid_elements[key] = elem
520521
model._type_to_id_map[elem.type].append(key)
521522

522-
def _add_thermal_element_object(self, elem: Union[CHBDYE, CHBDYG, CHBDYP]) -> None:
523+
def _add_thermal_element_object(self, elem: CHBDYE | CHBDYG | CHBDYP) -> None:
523524
"""same as add_element at the moment..."""
524525
self._add_element_object(elem)
525526

pyNastran/bdf/bdf_interface/assign_type.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def blank(card: BDFCard, ifield: int, fieldname: str, default=None) -> None:
222222
raise SyntaxError('%s = %r (field #%s) on card must be blank (not %s).\n'
223223
'card=%s' % (fieldname, svalue, ifield, dtype, card))
224224

225-
#def field(card: BDFCard, ifield: int, fieldname: str) -> Optional[Union[int, float, str]]:
225+
#def field(card: BDFCard, ifield: int, fieldname: str) -> Optional[int | float | str]:
226226
#"""
227227
#Parameters
228228
#----------
@@ -244,7 +244,7 @@ def blank(card: BDFCard, ifield: int, fieldname: str, default=None) -> None:
244244
#return integer_double_string_or_blank(card, ifield, fieldname, default=None)
245245

246246
def integer_double_string_or_blank(card: BDFCard, ifield: int, fieldname: str, default=None):
247-
# type (BDFCard, int, str, Union[int, float, str]) -> Optional[Union[int, float, str]]
247+
# type (BDFCard, int, str, int | float | str) -> Optional[int | float | str]
248248
"""
249249
Parameters
250250
----------
@@ -916,7 +916,7 @@ def _get_dtype(value):
916916
return dtype
917917

918918

919-
def integer_double_or_string(card: BDFCard, ifield: int, fieldname: str) -> Union[int, float, str]:
919+
def integer_double_or_string(card: BDFCard, ifield: int, fieldname: str) -> int | float | str:
920920
"""
921921
Casts a value to an integer/double/string
922922

pyNastran/bdf/bdf_interface/bdf_card.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def fields_defaults(self, i: int=0, j: Optional[int]=None, defaults: Any=None) -
147147
return out
148148

149149
def field(self, i: int,
150-
default: Optional[Union[int, float, str]]=None) -> Optional[Union[int, float, str]]:
150+
default: Optional[int | float | str]=None) -> Optional[int | float | str]:
151151
"""
152152
Gets the ith field on the card
153153

pyNastran/bdf/bdf_interface/subcase/cards.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
def encode_str_list(strings: list[str], encoding: str) -> list[bytes]:
1616
return [stri.encode(encoding) for stri in strings]
1717

18-
def encode_str_value_list(strings: list[Union[int, float, str]],
18+
def encode_str_value_list(strings: list[int | float | str],
1919
encoding: str) -> list[Union[int, float, bytes]]:
2020
values_bytes = [stri.encode(encoding) if isinstance(stri, str) else stri
2121
for stri in strings]

pyNastran/bdf/bdf_interface/subcase/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pyNastran.bdf.cards.collpase_card import collapse_thru_packs
1111

1212

13-
def expand_thru_case_control(data_in: list[Union[int, float, str]]) -> list[int]:
13+
def expand_thru_case_control(data_in: list[int | float | str]) -> list[int]:
1414
"""
1515
Expands a case control SET card
1616

pyNastran/bdf/cards/aero/aero.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,10 +1031,10 @@ def add_card(cls, card, comment=''):
10311031
label = string(card, 2, 'label')
10321032

10331033
cid1 = integer(card, 3, 'cid1')
1034-
alid1 = integer(card, 4, 'alid1')
1034+
aelist_id1 = integer(card, 4, 'alid1')
10351035

10361036
cid2 = integer_or_blank(card, 5, 'cid2')
1037-
alid2 = integer_or_blank(card, 6, 'alid2')
1037+
aelist_id2 = integer_or_blank(card, 6, 'alid2')
10381038

10391039
eff = double_or_blank(card, 7, 'eff', default=1.0)
10401040
ldw = string_or_blank(card, 8, 'ldw', default='LDW')
@@ -1053,21 +1053,10 @@ def add_card(cls, card, comment=''):
10531053
tqllim = integer_or_blank(card, 15, 'tqllim', default=0)
10541054
tqulim = integer_or_blank(card, 16, 'tqulim', default=0)
10551055
assert len(card) <= 17, f'len(AESURF card) = {len(card):d}\ncard={card}'
1056-
return AESURF(aesurf_id, label, cid1, alid1, cid2, alid2, eff, ldw,
1056+
return AESURF(aesurf_id, label, cid1, aelist_id1, cid2, aelist_id2, eff, ldw,
10571057
crefc, crefs, pllim, pulim, hmllim, hmulim,
10581058
tqllim, tqulim, comment=comment)
10591059

1060-
@property
1061-
def aesid(self) -> int:
1062-
return self.aesurf_id
1063-
@aesid.setter
1064-
def aesid(self, aesid: int) -> None:
1065-
self.aesurf_id = aesid
1066-
1067-
#@property
1068-
#def aesid_ref(self):
1069-
#return self.aesurf_ref
1070-
10711060
def Cid1(self) -> int:
10721061
if self.cid1_ref is not None:
10731062
return self.cid1_ref.cid

pyNastran/bdf/cards/optimization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ def add_card(cls, card: BDFCard, comment: str=''):
12871287
params[param] = val
12881288
return DOPTPRM(params, comment=comment)
12891289

1290-
def raw_fields(self) -> list[Union[int, float, str]]:
1290+
def raw_fields(self) -> list[int | float | str]:
12911291
list_fields = ['DOPTPRM']
12921292
for param, val in sorted(self.params.items()):
12931293
list_fields += [param, val]
@@ -1843,8 +1843,8 @@ def __init__(self, dresp_id: int, label: str,
18431843
response_type: str,
18441844
property_type: str,
18451845
region: int,
1846-
atta: Optional[Union[int, float, str]],
1847-
attb: Optional[Union[int, float, str]],
1846+
atta: Optional[int | float | str],
1847+
attb: Optional[int | float | str],
18481848
atti: list[int],
18491849
comment: str='', validate: bool=False):
18501850
"""

pyNastran/bdf/cards/properties/shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ class PCOMP(CompositeShellProperty):
691691
}
692692
_properties = ['_field_map', 'plies', 'nplies', 'material_ids']
693693
def update_by_pname_fid(self, pname_fid: Union[str, int],
694-
value: Union[int, float, str]) -> None:
694+
value: int | float | str) -> None:
695695
if isinstance(pname_fid, int):
696696
self._update_field_helper(pname_fid, value)
697697
elif pname_fid == 'Z0':

pyNastran/converters/tecplot/zone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __contains__(self, key: str) -> bool:
4545
return val_in
4646
return key in self._key_map
4747

48-
def __getitem__(self, key: str) -> Union[int, float, str]:
48+
def __getitem__(self, key: str) -> int | float | str:
4949
key_upper = key.upper()
5050
key2 = self._key_map.get(key_upper, key_upper)
5151
#print(f'key_upper={key_upper} key2={key2}')

0 commit comments

Comments
 (0)