Skip to content

Commit 8167e1a

Browse files
chore: bump pyright to 1.1.363 (#2232)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Updated Pyright version in workflow from `1.1.308` to `1.1.363`. - **Refactor** - Enhanced code readability and maintainability by adding type annotations to internal methods in `_detect.py`. - Improved clarity in data handling by adding type hints in the table printing function in `_matrix.py`. - **Bug Fixes** - Ensured proper handling of molecule creation and manipulation without type annotations in the `convertSMILES` method of the `Path` class in `_path.py`. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 311db70 commit 8167e1a

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

.github/workflows/pyright.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ jobs:
2525
- run: uv pip install --system -e .
2626
- uses: jakebailey/pyright-action@v2
2727
with:
28-
version: 1.1.308
28+
version: 1.1.363

reacnetgenerator/_detect.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,11 @@ def _compressvalue(self, x):
173173
return listtobytes(np.array(x))
174174

175175
@abstractmethod
176-
def _readNfunc(self, f):
176+
def _readNfunc(self, f) -> int:
177177
pass
178178

179179
@abstractmethod
180-
def _readstepfunc(self, item):
180+
def _readstepfunc(self, item) -> Tuple[List[bytes], Tuple[int, int]]:
181181
pass
182182

183183
def _connectmolecule(self, bond, level):
@@ -207,7 +207,7 @@ def _writemoleculetempfile(self, d):
207207
@_Detect.register_subclass("bond")
208208
@_Detect.register_subclass("lammpsbondfile")
209209
class _DetectLAMMPSbond(_Detect):
210-
def _readNfunc(self, f):
210+
def _readNfunc(self, f) -> int:
211211
iscompleted = False
212212
N = None
213213
atomtype = None
@@ -236,10 +236,10 @@ def _readNfunc(self, f):
236236
self.atomtype = atomtype
237237
return steplinenum
238238

239-
def _readstepfunc(self, item):
239+
def _readstepfunc(self, item) -> Tuple[List[bytes], Tuple[int, int]]:
240240
step, lines = item
241-
bond: list[Optional[Tuple[int]]] = [None] * self.N
242-
level: list[Optional[Tuple[int]]] = [None] * self.N
241+
bond: list[Optional[Tuple[int, ...]]] = [None] * self.N
242+
level: list[Optional[Tuple[int, ...]]] = [None] * self.N
243243
timestep = None
244244
for line in lines:
245245
if line:
@@ -390,7 +390,7 @@ def _readNfunc(self, f):
390390
self.atomtype = atomtype
391391
return steplinenum
392392

393-
def _readstepfunc(self, item):
393+
def _readstepfunc(self, item) -> Tuple[List[bytes], Tuple[int, int]]:
394394
step, lines = item
395395
step_atoms = []
396396
ss = []
@@ -439,7 +439,7 @@ def _readstepfunc(self, item):
439439
zhi = ss[2][1]
440440
boxsize = np.array(
441441
[
442-
[xhi - xlo, 0.0, 0.0], # type: ignore
442+
[xhi - xlo, 0.0, 0.0],
443443
[xy, yhi - ylo, 0.0],
444444
[xz, yz, zhi - zlo],
445445
]
@@ -477,7 +477,7 @@ def _readNfunc(self, f):
477477
steplinenum = N + 2
478478
return steplinenum
479479

480-
def _readstepfunc(self, item):
480+
def _readstepfunc(self, item) -> Tuple[List[bytes], Tuple[int, int]]:
481481
step, lines = item
482482
timestep = step, step
483483
step_atoms = []

reacnetgenerator/_matrix.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ def _printtable(self, allroute, timeaxis=None):
124124
if all(reactionnumber >= 0):
125125
table[tuple(reactionnumber)] = n_reaction
126126

127+
species_idx = pd.Index(species)
127128
df = pd.DataFrame(
128-
table[: len(species), : len(species)], index=species, columns=species
129+
table[: len(species), : len(species)],
130+
index=species_idx,
131+
columns=species_idx,
129132
)
130133
df.to_csv(
131134
self.tablefilename

reacnetgenerator/_path.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,13 @@ def convertSMILES(self, atoms, bonds):
258258
ValueError
259259
(RDKit error) Maximum BFS search size exceeded.
260260
"""
261-
m = Chem.RWMol(Chem.MolFromSmiles("")) # type: ignore
261+
m = Chem.RWMol(Chem.MolFromSmiles(""))
262262
d = {}
263263
for name, number in zip(self.atomnames[atoms], atoms):
264-
d[number] = m.AddAtom(Chem.Atom(name)) # type: ignore
264+
d[number] = m.AddAtom(Chem.Atom(name))
265265
for atom1, atom2, level in bonds:
266-
m.AddBond(d[atom1], d[atom2], Chem.BondType(level)) # type: ignore
267-
name = Chem.MolToSmiles(m) # type: ignore
266+
m.AddBond(d[atom1], d[atom2], Chem.BondType(level))
267+
name = Chem.MolToSmiles(m)
268268
return self._re(name)
269269

270270
def _getatomsandbonds(self, line):

reacnetgenerator/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)