Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .constraints/py3.6.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ flake8-plugin-utils==1.3.2
flake8-polyfill==1.0.2
flake8-pytest-style==1.5.0
flake8-rst-docstrings==0.2.3
flake8-type-ignore==0.1.0.post2
flake8-use-fstring==1.1
fuzzywuzzy==0.18.0
gitdb==4.0.7
Expand Down Expand Up @@ -104,7 +105,7 @@ pandocfilters==1.5.0
parso==0.8.2
particle==0.16.1
pathspec==0.9.0
pep517==0.11.1
pep517==0.12.0
pep8-naming==0.12.1
pexpect==4.8.0
pickleshare==0.7.5
Expand Down Expand Up @@ -178,6 +179,7 @@ tqdm==4.62.3
traitlets==4.3.3
typed-ast==1.4.3
types-docutils==0.17.1
types-pkg-resources==0.1.3
types-pyyaml==5.4.12
typing-extensions==3.10.0.2 ; python_version < "3.8.0"
urllib3==1.26.7
Expand Down
4 changes: 3 additions & 1 deletion .constraints/py3.7.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ flake8-plugin-utils==1.3.2
flake8-polyfill==1.0.2
flake8-pytest-style==1.5.0
flake8-rst-docstrings==0.2.3
flake8-type-ignore==0.1.0.post2
flake8-use-fstring==1.1
fuzzywuzzy==0.18.0
gitdb==4.0.7
Expand Down Expand Up @@ -103,7 +104,7 @@ pandocfilters==1.5.0
parso==0.8.2
particle==0.16.1
pathspec==0.9.0
pep517==0.11.1
pep517==0.12.0
pep8-naming==0.12.1
pexpect==4.8.0
pickleshare==0.7.5
Expand Down Expand Up @@ -177,6 +178,7 @@ tqdm==4.62.3
traitlets==5.1.0
typed-ast==1.4.3
types-docutils==0.17.1
types-pkg-resources==0.1.3
types-pyyaml==5.4.12
typing-extensions==3.10.0.2 ; python_version < "3.8.0"
urllib3==1.26.7
Expand Down
4 changes: 3 additions & 1 deletion .constraints/py3.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ flake8-plugin-utils==1.3.2
flake8-polyfill==1.0.2
flake8-pytest-style==1.5.0
flake8-rst-docstrings==0.2.3
flake8-type-ignore==0.1.0.post2
flake8-use-fstring==1.1
fuzzywuzzy==0.18.0
gitdb==4.0.7
Expand Down Expand Up @@ -102,7 +103,7 @@ pandocfilters==1.5.0
parso==0.8.2
particle==0.16.1
pathspec==0.9.0
pep517==0.11.1
pep517==0.12.0
pep8-naming==0.12.1
pexpect==4.8.0
pickleshare==0.7.5
Expand Down Expand Up @@ -175,6 +176,7 @@ tox==3.24.4
tqdm==4.62.3
traitlets==5.1.0
types-docutils==0.17.1
types-pkg-resources==0.1.3
types-pyyaml==5.4.12
typing-extensions==3.10.0.2
urllib3==1.26.7
Expand Down
4 changes: 3 additions & 1 deletion .constraints/py3.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ flake8-plugin-utils==1.3.2
flake8-polyfill==1.0.2
flake8-pytest-style==1.5.0
flake8-rst-docstrings==0.2.3
flake8-type-ignore==0.1.0.post2
flake8-use-fstring==1.1
fuzzywuzzy==0.18.0
gitdb==4.0.7
Expand Down Expand Up @@ -102,7 +103,7 @@ pandocfilters==1.5.0
parso==0.8.2
particle==0.16.1
pathspec==0.9.0
pep517==0.11.1
pep517==0.12.0
pep8-naming==0.12.1
pexpect==4.8.0
pickleshare==0.7.5
Expand Down Expand Up @@ -175,6 +176,7 @@ tox==3.24.4
tqdm==4.62.3
traitlets==5.1.0
types-docutils==0.17.1
types-pkg-resources==0.1.3
types-pyyaml==5.4.12
typing-extensions==3.10.0.2
urllib3==1.26.7
Expand Down
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ ignore = # more info: https://www.flake8rules.com/
RST201 # block quote ends without a blank line (black formatting)
RST301 # unexpected indentation (related to google style docstring)
W503 # https://github.com/psf/black#line-breaks--binary-operators
; enforce type ignore with mypy error codes (TI100)
TI101, TI102, TI103, TI104, TI105, TI106, TI107, TI108, TI109, TI11, TI12, TI13
rst-roles =
attr,
cite,
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -c .constraints/py3.7.txt -e .[sty]
pip install -c .constraints/py3.8.txt -e .[sty]
- name: Run non-local pre-commit hooks
run: |
pre-commit run flake8 -a --color always
Expand Down
3 changes: 3 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[mypy]
disallow_incomplete_defs = True
disallow_untyped_defs = True
show_error_codes = True
warn_unused_configs = True
files =
**/*.py,
Expand All @@ -22,6 +23,8 @@ ignore_missing_imports = True
ignore_missing_imports = True
[mypy-particle.*]
ignore_missing_imports = True
[mypy-pybtex.*]
ignore_missing_imports = True
[mypy-pydot.*]
ignore_missing_imports = True
[mypy-setuptools.*]
Expand Down
3 changes: 2 additions & 1 deletion docs/abbreviate_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ def new_type_to_xref(
)


sphinx.domains.python.type_to_xref = new_type_to_xref # noqa: F811
def abbreviate_signature() -> None:
sphinx.domains.python.type_to_xref = new_type_to_xref
48 changes: 24 additions & 24 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# type: ignore

"""Configuration file for the Sphinx documentation builder.

This file only contains a selection of the most common options. For a full
Expand All @@ -12,8 +10,24 @@
import subprocess
import sys

# pyright: reportMissingImports=false
import sphobjinv as soi
from pkg_resources import get_distribution
from pybtex.database import Entry
from pybtex.plugin import register_plugin
from pybtex.richtext import Tag, Text
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
from pybtex.style.template import (
FieldIsMissing,
Node,
_format_list,
field,
href,
join,
node,
sentence,
words,
)

# -- Project information -----------------------------------------------------
project = "QRules"
Expand All @@ -28,8 +42,9 @@

# -- Generate API ------------------------------------------------------------
sys.path.insert(0, os.path.abspath("."))
import abbreviate_signature
from abbreviate_signature import abbreviate_signature

abbreviate_signature()
shutil.rmtree("api", ignore_errors=True)
subprocess.call(
" ".join(
Expand Down Expand Up @@ -248,23 +263,8 @@


# Specify bibliography style
from pybtex.plugin import register_plugin
from pybtex.richtext import Tag, Text
from pybtex.style.formatting.unsrt import Style as UnsrtStyle
from pybtex.style.template import (
FieldIsMissing,
_format_list,
field,
href,
join,
node,
sentence,
words,
)


@node
def et_al(children, data, sep="", sep2=None, last_sep=None):
def et_al(children, data, sep="", sep2=None, last_sep=None): # type: ignore[no-untyped-def]
if sep2 is None:
sep2 = sep
if last_sep is None:
Expand All @@ -281,7 +281,7 @@ def et_al(children, data, sep="", sep2=None, last_sep=None):


@node
def names(children, context, role, **kwargs):
def names(children, context, role, **kwargs): # type: ignore[no-untyped-def]
"""Return formatted names."""
assert not children
try:
Expand All @@ -297,10 +297,10 @@ def names(children, context, role, **kwargs):


class MyStyle(UnsrtStyle):
def __init__(self):
def __init__(self) -> None:
super().__init__(abbreviate_names=True)

def format_names(self, role, as_sentence=True):
def format_names(self, role: Entry, as_sentence: bool = True) -> Node:
formatted_names = names(
role, sep=", ", sep2=" and ", last_sep=", and "
)
Expand All @@ -309,15 +309,15 @@ def format_names(self, role, as_sentence=True):
else:
return formatted_names

def format_url(self, e):
def format_url(self, e: Entry) -> Node:
return words[
href[
field("url", raw=True),
field("url", raw=True, apply_func=remove_http),
]
]

def format_isbn(self, e):
def format_isbn(self, e: Entry) -> Node:
return href[
join[
"https://isbnsearch.org/isbn/",
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ target-version = [
"py36",
"py37",
"py38",
"py39",
]
include = '\.pyi?$'
exclude = '''
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ lint =
flake8-comprehensions
flake8-pytest-style
flake8-rst-docstrings
flake8-type-ignore
flake8-use-fstring
mypy >= 0.570 # attrs support
mypy >= 0.730 # attrs and error code support
pep8-naming
pydocstyle
pylint >= 2.5 # good-names-rgxs
Expand All @@ -101,6 +102,7 @@ sty =
%(test)s # for pytest type hints
pre-commit >= 1.4.0
types-docutils
types-pkg-resources
types-PyYAML
dev =
%(all)s
Expand Down
6 changes: 3 additions & 3 deletions src/qrules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def check_reaction_violations( # pylint: disable=too-many-arguments
"""
# pylint: disable=too-many-locals
if not isinstance(initial_state, (list, tuple)):
initial_state = [initial_state] # type: ignore
initial_state = [initial_state] # type: ignore[list-item]

if particle_db is None:
particle_db = load_pdg()
Expand Down Expand Up @@ -375,9 +375,9 @@ def generate_transitions( # pylint: disable=too-many-arguments
and len(initial_state) == 2
and isinstance(initial_state[0], str)
):
initial_state = [initial_state] # type: ignore
initial_state = [initial_state] # type: ignore[list-item]
stm = StateTransitionManager(
initial_state=initial_state, # type: ignore
initial_state=initial_state, # type: ignore[arg-type]
final_state=final_state,
particle_db=particle_db,
allowed_intermediate_particles=allowed_intermediate_particles,
Expand Down
3 changes: 2 additions & 1 deletion src/qrules/_implementers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def repr_pretty(self: Any, p: PrettyPrinter, cycle: bool) -> None:
p.breakable()
p.text(")")

decorated_class._repr_pretty_ = repr_pretty # type: ignore # pylint: disable=protected-access
# pylint: disable=protected-access
decorated_class._repr_pretty_ = repr_pretty # type: ignore[attr-defined]
return decorated_class

return decorator
Loading