Skip to content

Commit

Permalink
ruff automatic type annotations (#3498)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
janosh authored Dec 14, 2023
1 parent 529eceb commit d5a7c92
Show file tree
Hide file tree
Showing 31 changed files with 200 additions and 404 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
rev: v0.1.8
hooks:
- id: ruff
args: [--fix]
args: [--fix, --unsafe-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
151 changes: 0 additions & 151 deletions docs/_modules/pymatgen/cli/pmg_query.html

This file was deleted.

3 changes: 0 additions & 3 deletions pymatgen/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (c) Materials Virtual Lab.
# Distributed under the terms of the BSD License.

"""This package contains various command line interfaces for common
pymatgen functionality such as file conversion, etc. Entry points to these
interfaces are defined in setup.py.
Expand Down
4 changes: 3 additions & 1 deletion pymatgen/cli/get_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__author__ = "David Waroquiers"


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

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

return 0


if __name__ == "__main__":
raise SystemExit(main())
2 changes: 0 additions & 2 deletions pymatgen/cli/pmg.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from pymatgen.cli.pmg_config import configure_pmg
from pymatgen.cli.pmg_plot import plot
from pymatgen.cli.pmg_potcar import generate_potcar
from pymatgen.cli.pmg_query import do_query
from pymatgen.cli.pmg_structure import analyze_structures
from pymatgen.core import SETTINGS
from pymatgen.core.structure import Structure
Expand Down Expand Up @@ -244,7 +243,6 @@ def main():
"By default, the Materials Project id, formula, spacegroup, "
"energy per atom, energy above hull are shown.",
)
parser_query.set_defaults(func=do_query)

parser_plot = subparsers.add_parser("plot", help="Plotting tool for DOS, CHGCAR, XRD, etc.")
group = parser_plot.add_mutually_exclusive_group(required=True)
Expand Down
63 changes: 0 additions & 63 deletions pymatgen/cli/pmg_query.py

This file was deleted.

4 changes: 2 additions & 2 deletions pymatgen/core/bonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _load_bond_length_data():
class CovalentBond:
"""Defines a covalent bond between two sites."""

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

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


Expand Down
Loading

0 comments on commit d5a7c92

Please sign in to comment.