Skip to content

Commit

Permalink
Merge branch 'wip/bump_black_flake8_mypy' into 'master'
Browse files Browse the repository at this point in the history
Bump Flake8, Black, MyPy

See merge request it/e3-testsuite!24
  • Loading branch information
elsaferrara committed Mar 22, 2024
2 parents 8a25516 + 4a1b3a9 commit 43e3a01
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
exclude = .git,__pycache__,build,dist,.tox
ignore = A003, C901, E203, E266, E501, W503,D100,D101,D102,D102,D103,D104,D105,D106,D107,D203,D403,D213,B028,B906,B907
ignore = A003, C901, E203, E266, E501, W503,D100,D101,D102,D102,D103,D104,D105,D106,D107,D203,D403,D213,B028,B906,B907,E704
# line length is intentionally set to 80 here because black uses Bugbear
# See https://github.com/psf/black/blob/master/README.md#line-length for more details
max-line-length = 80
Expand Down
44 changes: 23 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
repos:
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-builtins
- flake8-comprehensions
- flake8-docstrings
- flake8-rst-docstrings
- pygments
args: [--config=.flake8]
- id: flake8
additional_dependencies:
- flake8-bugbear
- flake8-builtins
- flake8-comprehensions
- flake8-docstrings
- flake8-rst-docstrings
- pygments
args:
- --config=.flake8
- repo: https://github.com/ambv/black
rev: 23.1.0
rev: 24.2.0
hooks:
- id: black
args: ["--line-length=79"]
- id: black
args:
- --line-length=79
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.1.1
rev: v1.8.0
hooks:
- id: mypy
files: '\.py$'
exclude: '^(tests|doc)/.+$'
additional_dependencies:
- types-PyYAML
- types-setuptools
- id: mypy
files: \.py$
exclude: ^(tests|doc)/.+$
additional_dependencies:
- types-PyYAML
- types-setuptools
5 changes: 3 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))

import os.path
import sys

# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -178,8 +180,7 @@
# A list of files that should not be packed into the epub file.
epub_exclude_files = ["search.html"]

import os.path
import sys

sys.path.insert(0, os.path.abspath("../src"))
extensions += ["autoapi.extension"]
autoapi_type = "python"
Expand Down
16 changes: 9 additions & 7 deletions src/e3/testsuite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ def testsuite_main(self, args: Optional[List[str]] = None) -> int:
action="store_true",
help="Run only tests that did not pass in the previous testsuite"
" run. This attempts to find successful tests in the report stored"
" at the location where this run will create the testsuite report."
" at the location where this run will create the testsuite report.",
)
parser.add_argument(
"sublist", metavar="tests", nargs="*", default=[], help="test"
Expand Down Expand Up @@ -543,7 +543,9 @@ def should_skip(pt: ParsedTest) -> bool:
"""
entry = self.old_report_index.entries.get(pt.test_name)
return entry is not None and entry.status in (
TestStatus.PASS, TestStatus.XFAIL, TestStatus.XPASS
TestStatus.PASS,
TestStatus.XFAIL,
TestStatus.XPASS,
)

self.test_list = [
Expand Down Expand Up @@ -707,7 +709,7 @@ def helper(spec: str) -> None:
# Don't descend into internal VCS directories, because it will
# likely generate a lot of unnecessary I/O operations and we
# don't expect to find any tests there anyway.
for vcsdir in ['.git', '.svn', 'CVS']:
for vcsdir in [".git", ".svn", "CVS"]:
if vcsdir in dirnames:
dirnames.remove(vcsdir)

Expand Down Expand Up @@ -1113,10 +1115,10 @@ def collect_result(job: ProcessTestFragment) -> None:
job.collect_result()
self.collect_result(job)

scheduler: MultiprocessScheduler[
FragmentData, ProcessTestFragment
] = MultiprocessScheduler(
dag, job_factory, collect_result, jobs=self.main.args.jobs
scheduler: MultiprocessScheduler[FragmentData, ProcessTestFragment] = (
MultiprocessScheduler(
dag, job_factory, collect_result, jobs=self.main.args.jobs
)
)

# See corresponding code/comment in run_multithread_mainloop
Expand Down
1 change: 0 additions & 1 deletion src/e3/testsuite/_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Internal helpers for e3.testsuite."""


import warnings
from typing import Any, Callable, List, TypeVar, cast

Expand Down
3 changes: 1 addition & 2 deletions src/e3/testsuite/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@


class FragmentCallback(Protocol):
def __call__(self, previous_values: Dict[str, Any], slot: int) -> None:
...
def __call__(self, previous_values: Dict[str, Any], slot: int) -> None: ...


@dataclass
Expand Down
3 changes: 1 addition & 2 deletions src/e3/testsuite/report/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@


class SupportsLessThan(Protocol):
def __lt__(self, other: SupportsLessThan) -> bool:
...
def __lt__(self, other: SupportsLessThan) -> bool: ...


KeyType = TypeVar("KeyType")
Expand Down
18 changes: 10 additions & 8 deletions src/e3/testsuite/report/xunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def escape_text(text: str) -> str:
for i, c in enumerate(result):
# Replace non-printable characters with their Python escape sequence,
# but strip quotes.
if c < ' ' and c != '\n':
if c < " " and c != "\n":
result[i] = ascii(c)[1:-1]
return "".join(result)

Expand Down Expand Up @@ -197,9 +197,7 @@ def run(self, filename: str) -> None:
for testcase in testsuite:
# Skip "properties", "system-out" and "system-err" elements so
# that we process only "testcase" ones.
if testcase.tag in {
"properties", "system-out", "system-err"
}:
if testcase.tag in {"properties", "system-out", "system-err"}:
continue
assert testcase.tag == "testcase"

Expand Down Expand Up @@ -255,10 +253,14 @@ def run(self, filename: str) -> None:
# test result message, create a single message for the
# result to store in the report.
new_message = (
f"{message} ({xfail_message})"
if message
else xfail_message
) if xfail_message else message
(
f"{message} ({xfail_message})"
if message
else xfail_message
)
if xfail_message
else message
)

# xUnit tests often use the ERROR status for issues that
# are not testsuite bugs (i.e. for what we call "failures"
Expand Down
8 changes: 5 additions & 3 deletions tests/tests/test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ def run(self, prev, slot):
def analyze(self, prev, slot):
self.result.set_status(
Status.PASS,
TestEnable.ENABLED_MSG
if self.env.use_multiprocessing
else TestEnable.DISABLED_MSG,
(
TestEnable.ENABLED_MSG
if self.env.use_multiprocessing
else TestEnable.DISABLED_MSG
),
)
self.push_result()

Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ commands=
[testenv:checkstyle]
basepython = python
deps =
black==23.1.0
flake8==6.0.0
black==24.2.0
flake8==7.0.0
flake8-docstrings
flake8-rst-docstrings
mypy==1.1.1
mypy==1.8.0
types-PyYAML
types-setuptools
commands =
Expand Down Expand Up @@ -71,7 +71,7 @@ commands =
python -msphinx -M html {toxinidir}/docs/source {toxinidir}/docs/build

[flake8]
ignore = D100,D101,D102,D102,D103,D104,D105,D106,D107,D203,D403,D213,E123,E133,E241,E242,W503
ignore = D100,D101,D102,D102,D103,D104,D105,D106,D107,D203,D403,D213,E123,E133,E241,E242,W503,E704

[pytest]
addopts = --failed-first

0 comments on commit 43e3a01

Please sign in to comment.