Skip to content

Commit d5a7c92

Browse files
authored
ruff automatic type annotations (#3498)
* rm pymatgen/cli/pmg_query.py which used the recently removed legacy MPRester ruff pre-commit enable --unsafe-fixes * ruff pymatgen/core --select ANN --fix --unsafe-fixes * ruff pymatgen/electronic_structure --select ANN --fix --unsafe-fixes * remove np.array call * del broken do_query import from pymatgen.cli.pmg_query * split test_entrypoint into pmg_analyze, pmg_structure, pmg_diff
1 parent 529eceb commit d5a7c92

31 files changed

+200
-404
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
rev: v0.1.8
1212
hooks:
1313
- id: ruff
14-
args: [--fix]
14+
args: [--fix, --unsafe-fixes]
1515
- id: ruff-format
1616

1717
- repo: https://github.com/pre-commit/pre-commit-hooks

docs/_modules/pymatgen/cli/pmg_query.html

Lines changed: 0 additions & 151 deletions
This file was deleted.

pymatgen/cli/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Copyright (c) Materials Virtual Lab.
2-
# Distributed under the terms of the BSD License.
3-
41
"""This package contains various command line interfaces for common
52
pymatgen functionality such as file conversion, etc. Entry points to these
63
interfaces are defined in setup.py.

pymatgen/cli/get_environment.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
__author__ = "David Waroquiers"
1212

1313

14-
def main():
14+
def main() -> int:
1515
"""Main function for get_environment CLI."""
1616
parser = ArgumentParser(description="Welcome to the Chemical Environment Package.")
1717
setup_help = "Used to setup the configuration of the package "
@@ -43,6 +43,8 @@ def main():
4343

4444
print("Thank you for using the ChemEnv package")
4545

46+
return 0
47+
4648

4749
if __name__ == "__main__":
4850
raise SystemExit(main())

pymatgen/cli/pmg.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from pymatgen.cli.pmg_config import configure_pmg
1414
from pymatgen.cli.pmg_plot import plot
1515
from pymatgen.cli.pmg_potcar import generate_potcar
16-
from pymatgen.cli.pmg_query import do_query
1716
from pymatgen.cli.pmg_structure import analyze_structures
1817
from pymatgen.core import SETTINGS
1918
from pymatgen.core.structure import Structure
@@ -244,7 +243,6 @@ def main():
244243
"By default, the Materials Project id, formula, spacegroup, "
245244
"energy per atom, energy above hull are shown.",
246245
)
247-
parser_query.set_defaults(func=do_query)
248246

249247
parser_plot = subparsers.add_parser("plot", help="Plotting tool for DOS, CHGCAR, XRD, etc.")
250248
group = parser_plot.add_mutually_exclusive_group(required=True)

pymatgen/cli/pmg_query.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

pymatgen/core/bonds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _load_bond_length_data():
3333
class CovalentBond:
3434
"""Defines a covalent bond between two sites."""
3535

36-
def __init__(self, site1: Site, site2: Site):
36+
def __init__(self, site1: Site, site2: Site) -> None:
3737
"""Initializes a covalent bond between two sites.
3838
3939
Args:
@@ -103,7 +103,7 @@ def is_bonded(site1, site2, tol: float = 0.2, bond_order: float | None = None, d
103103
return dist < (1 + tol) * default_bl
104104
raise ValueError(f"No bond data for elements {syms[0]} - {syms[1]}")
105105

106-
def __repr__(self):
106+
def __repr__(self) -> str:
107107
return f"Covalent bond between {self.site1} and {self.site2}"
108108

109109

0 commit comments

Comments
 (0)