Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit c5dbe82

Browse files
committed
upgrade/fix tests
1 parent 8d9dcdb commit c5dbe82

19 files changed

+71
-32
lines changed

Diff for: .github/workflows/test.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: [3.7, 3.8, 3.9]
10+
python-version: ["3.7", "3.8", "3.9", "3.10"]
1111

1212
steps:
1313
- uses: actions/checkout@v2
@@ -16,6 +16,6 @@ jobs:
1616
with:
1717
python-version: ${{ matrix.python-version }}
1818
- name: Install Python Dependencies
19-
run: pip install -r requirements/ci.txt
19+
run: pip install -r requirements/nox-deps.txt
2020
- name: Run Tests
21-
run: tox
21+
run: nox -s test

Diff for: flake8_idom_hooks/__init__.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
from pkg_resources import (
2-
get_distribution as _get_distribution,
3-
DistributionNotFound as _DistributionNotFound,
4-
)
1+
from pkg_resources import DistributionNotFound as _DistributionNotFound
2+
from pkg_resources import get_distribution as _get_distribution
53

64
try:
75
__version__: str = _get_distribution(__name__).version

Diff for: flake8_idom_hooks/exhaustive_deps.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import ast
2-
from typing import Optional, Union, Set
3-
4-
from .utils import is_hook_def, is_component_def, ErrorVisitor, set_current
2+
from typing import Optional, Set, Union
53

4+
from .utils import ErrorVisitor, is_component_def, is_hook_def, set_current
65

76
HOOKS_WITH_DEPS = ("use_effect", "use_callback", "use_memo")
87

Diff for: flake8_idom_hooks/rules_of_hooks.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import ast
2-
from typing import Union, Optional
2+
from typing import Optional, Union
33

44
from .utils import (
5-
is_hook_def,
6-
is_component_def,
75
ErrorVisitor,
6+
is_component_def,
7+
is_hook_def,
88
is_hook_function_name,
99
set_current,
1010
)

Diff for: flake8_idom_hooks/run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import ast
44

5-
from .utils import ErrorVisitor
65
from .exhaustive_deps import ExhaustiveDepsVisitor
76
from .rules_of_hooks import RulesOfHooksVisitor
7+
from .utils import ErrorVisitor
88

99

1010
def run_checks(

Diff for: flake8_idom_hooks/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ast
22
from contextlib import contextmanager
3-
from typing import List, Tuple, Iterator, Any
3+
from typing import Any, Iterator, List, Tuple
44

55

66
@contextmanager

Diff for: noxfile.py

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from pathlib import Path
2+
3+
from nox import Session, session
4+
5+
ROOT = Path(".")
6+
REQUIREMENTS_DIR = ROOT / "requirements"
7+
8+
9+
@session
10+
def test(session: Session) -> None:
11+
session.notify("test_style")
12+
session.notify("test_types")
13+
session.notify("test_suite")
14+
15+
16+
@session
17+
def test_style(session: Session) -> None:
18+
install_requirements(session, "style")
19+
session.run("isort", "--check", ".")
20+
session.run("flake8", ".")
21+
22+
23+
@session
24+
def test_types(session: Session) -> None:
25+
install_requirements(session, "types")
26+
session.run("mypy", "--strict", "flake8_idom_hooks")
27+
28+
29+
@session
30+
def test_suite(session: Session) -> None:
31+
install_requirements(session, "test-env")
32+
session.run("pytest", "tests")
33+
34+
35+
def install_requirements(session: Session, name: str) -> None:
36+
session.install("-r", str(REQUIREMENTS_DIR / f"{name}.txt"))

Diff for: pyproject.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.isort]
6+
profile = "black"

Diff for: requirements.txt

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
-r requirements/dev.txt
2-
-r requirements/prod.txt
3-
-r requirements/test.txt
4-
-r requirements/lint.txt
1+
-r requirements/nox-deps.txt
2+
-r requirements/pkg-deps.txt
3+
-r requirements/style.txt
4+
-r requirements/test-env.txt
5+
-r requirements/types.txt

Diff for: requirements/ci.txt

-3
This file was deleted.

Diff for: requirements/dev.txt

-2
This file was deleted.

Diff for: requirements/nox-deps.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nox
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
flake8 >=3.7
2+
black

Diff for: requirements/style.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
flake8 >=3.7
2+
black
3+
isort
4+
flake8-tidy-imports
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
flake8 >=3.7
2-
black
31
mypy
42
types-setuptools

Diff for: setup.cfg

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ warn_unused_ignores = True
77
[flake8]
88
ignore = E203, E266, E501, W503, F811, N802
99
max-line-length = 88
10-
max-complexity = 18
11-
exclude =
12-
.eggs/*
13-
.tox/*
10+
extend-exclude =
11+
.nox
12+
venv
13+
.venv
1414
tests/hook_usage_test_cases.py
1515

1616
[coverage:report]

Diff for: setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
23
import setuptools
34

45
# the name of the project
@@ -46,7 +47,7 @@
4647

4748

4849
requirements = []
49-
with open(os.path.join(here, "requirements", "prod.txt"), "r") as f:
50+
with open(os.path.join(here, "requirements", "pkg-deps.txt"), "r") as f:
5051
for line in map(str.strip, f):
5152
if not line.startswith("#"):
5253
requirements.append(line)

Diff for: tests/test_flake8_idom_hooks.py

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from flake8_idom_hooks import Plugin
77

8-
98
options_manager = OptionManager("test", "0.0.0")
109
Plugin.add_options(options_manager)
1110

0 commit comments

Comments
 (0)