Skip to content

Commit

Permalink
chore: bump pyright to 1.1.363 (#2232)
Browse files Browse the repository at this point in the history
<!-- 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 <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] committed May 17, 2024
1 parent 311db70 commit 8167e1a
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
- run: uv pip install --system -e .
- uses: jakebailey/pyright-action@v2
with:
version: 1.1.308
version: 1.1.363
18 changes: 9 additions & 9 deletions reacnetgenerator/_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ def _compressvalue(self, x):
return listtobytes(np.array(x))

@abstractmethod
def _readNfunc(self, f):
def _readNfunc(self, f) -> int:
pass

@abstractmethod
def _readstepfunc(self, item):
def _readstepfunc(self, item) -> Tuple[List[bytes], Tuple[int, int]]:
pass

def _connectmolecule(self, bond, level):
Expand Down Expand Up @@ -207,7 +207,7 @@ def _writemoleculetempfile(self, d):
@_Detect.register_subclass("bond")
@_Detect.register_subclass("lammpsbondfile")
class _DetectLAMMPSbond(_Detect):
def _readNfunc(self, f):
def _readNfunc(self, f) -> int:
iscompleted = False
N = None
atomtype = None
Expand Down Expand Up @@ -236,10 +236,10 @@ def _readNfunc(self, f):
self.atomtype = atomtype
return steplinenum

def _readstepfunc(self, item):
def _readstepfunc(self, item) -> Tuple[List[bytes], Tuple[int, int]]:
step, lines = item
bond: list[Optional[Tuple[int]]] = [None] * self.N
level: list[Optional[Tuple[int]]] = [None] * self.N
bond: list[Optional[Tuple[int, ...]]] = [None] * self.N
level: list[Optional[Tuple[int, ...]]] = [None] * self.N
timestep = None
for line in lines:
if line:
Expand Down Expand Up @@ -390,7 +390,7 @@ def _readNfunc(self, f):
self.atomtype = atomtype
return steplinenum

def _readstepfunc(self, item):
def _readstepfunc(self, item) -> Tuple[List[bytes], Tuple[int, int]]:
step, lines = item
step_atoms = []
ss = []
Expand Down Expand Up @@ -439,7 +439,7 @@ def _readstepfunc(self, item):
zhi = ss[2][1]
boxsize = np.array(
[
[xhi - xlo, 0.0, 0.0], # type: ignore
[xhi - xlo, 0.0, 0.0],
[xy, yhi - ylo, 0.0],
[xz, yz, zhi - zlo],
]
Expand Down Expand Up @@ -477,7 +477,7 @@ def _readNfunc(self, f):
steplinenum = N + 2
return steplinenum

def _readstepfunc(self, item):
def _readstepfunc(self, item) -> Tuple[List[bytes], Tuple[int, int]]:
step, lines = item
timestep = step, step
step_atoms = []
Expand Down
5 changes: 4 additions & 1 deletion reacnetgenerator/_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ def _printtable(self, allroute, timeaxis=None):
if all(reactionnumber >= 0):
table[tuple(reactionnumber)] = n_reaction

species_idx = pd.Index(species)
df = pd.DataFrame(
table[: len(species), : len(species)], index=species, columns=species
table[: len(species), : len(species)],
index=species_idx,
columns=species_idx,
)
df.to_csv(
self.tablefilename
Expand Down
8 changes: 4 additions & 4 deletions reacnetgenerator/_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ def convertSMILES(self, atoms, bonds):
ValueError
(RDKit error) Maximum BFS search size exceeded.
"""
m = Chem.RWMol(Chem.MolFromSmiles("")) # type: ignore
m = Chem.RWMol(Chem.MolFromSmiles(""))
d = {}
for name, number in zip(self.atomnames[atoms], atoms):
d[number] = m.AddAtom(Chem.Atom(name)) # type: ignore
d[number] = m.AddAtom(Chem.Atom(name))
for atom1, atom2, level in bonds:
m.AddBond(d[atom1], d[atom2], Chem.BondType(level)) # type: ignore
name = Chem.MolToSmiles(m) # type: ignore
m.AddBond(d[atom1], d[atom2], Chem.BondType(level))
name = Chem.MolToSmiles(m)
return self._re(name)

def _getatomsandbonds(self, line):
Expand Down
Empty file added reacnetgenerator/py.typed
Empty file.

0 comments on commit 8167e1a

Please sign in to comment.