Skip to content

Commit 1e0bf4e

Browse files
committed
maint: remove poetry from noxfile etc
1 parent bf17e91 commit 1e0bf4e

File tree

9 files changed

+47
-155
lines changed

9 files changed

+47
-155
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[flake8]
22
select = B,B9,C,D,DAR,E,F,N,RST,S,W,TC,TC1
3-
ignore = E203,E501,RST201,RST203,RST301,W503,B902,B905,RST304
3+
ignore = D202,E203,E501,RST201,RST203,RST301,W503,B902,B905,RST304
44
max-line-length = 80
55
max-complexity = 10
66
docstring-convention = google

.github/workflows/tests.yml

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ jobs:
1616
- { python-version: 3.9, os: ubuntu-latest, session: "tests" }
1717
- { python-version: 3.8, os: ubuntu-latest, session: "tests" }
1818
- { python-version: 3.9, os: ubuntu-latest, session: "pre-commit" }
19-
- { python-version: 3.9, os: ubuntu-latest, session: "safety" }
20-
- { python-version: 3.9, os: ubuntu-latest, session: "xdoctest" }
19+
- { python-version: 3.9, os: ubuntu-latest, session: "doctest" }
2120
- { python-version: 3.9, os: ubuntu-latest, session: "docs-build" }
2221

2322
env:
@@ -32,19 +31,10 @@ jobs:
3231
with:
3332
python-version: ${{ matrix.python-version }}
3433

35-
- name: Upgrade pip
36-
run: |
37-
pip install --constraint=.github/workflows/constraints.txt pip
38-
pip --version
39-
40-
- name: Install Poetry
41-
run: |
42-
pip install --constraint=.github/workflows/constraints.txt poetry
43-
poetry --version
44-
4534
- name: Install Nox
4635
run: |
47-
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
36+
pip install --upgrade pip
37+
pip install nox
4838
nox --version
4939
5040
- name: Compute pre-commit cache key
@@ -103,19 +93,10 @@ jobs:
10393
with:
10494
python-version: 3.9
10595

106-
- name: Upgrade pip
107-
run: |
108-
pip install --constraint=.github/workflows/constraints.txt pip
109-
pip --version
110-
111-
- name: Install Poetry
112-
run: |
113-
pip install --constraint=.github/workflows/constraints.txt poetry
114-
poetry --version
115-
11696
- name: Install Nox
11797
run: |
118-
pip install --constraint=.github/workflows/constraints.txt nox nox-poetry
98+
pip install --upgrade pip
99+
pip install nox
119100
nox --version
120101
121102
- name: Download coverage data

noxfile.py

Lines changed: 9 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -2,129 +2,30 @@
22
import shutil
33
import sys
44
from pathlib import Path
5-
from textwrap import dedent
65

76
import nox
8-
9-
try:
10-
from nox_poetry import Session
11-
from nox_poetry import session
12-
except ImportError:
13-
message = f"""\
14-
Nox failed to import the 'nox-poetry' package.
15-
16-
Please install it using the following command:
17-
18-
{sys.executable} -m pip install nox-poetry"""
19-
raise SystemExit(dedent(message)) from None
7+
from nox import Session
8+
from nox import session
209

2110

2211
package = "protosym"
2312
python_versions = ["3.9", "3.8"]
2413
nox.needs_version = ">= 2021.6.6"
2514
nox.options.sessions = (
2615
"pre-commit",
27-
"safety",
2816
"mypy",
2917
"tests",
30-
# "typeguard", disabled because it conflicts with if TYPE_CHECKING
31-
"xdoctest",
18+
"doctest",
3219
"docs-build",
3320
)
3421

3522

36-
def activate_virtualenv_in_precommit_hooks(session: Session) -> None:
37-
"""Activate virtualenv in hooks installed by pre-commit.
38-
39-
This function patches git hooks installed by pre-commit to activate the
40-
session's virtual environment. This allows pre-commit to locate hooks in
41-
that environment when invoked from git.
42-
43-
Args:
44-
session: The Session object.
45-
"""
46-
if session.bin is None:
47-
return
48-
49-
virtualenv = session.env.get("VIRTUAL_ENV")
50-
if virtualenv is None:
51-
return
52-
53-
hookdir = Path(".git") / "hooks"
54-
if not hookdir.is_dir():
55-
return
56-
57-
for hook in hookdir.iterdir():
58-
if hook.name.endswith(".sample") or not hook.is_file():
59-
continue
60-
61-
text = hook.read_text()
62-
bindir = repr(session.bin)[1:-1] # strip quotes
63-
if not (
64-
Path("A") == Path("a") and bindir.lower() in text.lower() or bindir in text
65-
):
66-
continue
67-
68-
lines = text.splitlines()
69-
if not (lines[0].startswith("#!") and "python" in lines[0].lower()):
70-
continue
71-
72-
header = dedent(
73-
f"""\
74-
import os
75-
os.environ["VIRTUAL_ENV"] = {virtualenv!r}
76-
os.environ["PATH"] = os.pathsep.join((
77-
{session.bin!r},
78-
os.environ.get("PATH", ""),
79-
))
80-
"""
81-
)
82-
83-
lines.insert(1, header)
84-
hook.write_text("\n".join(lines))
85-
86-
8723
@session(name="pre-commit", python="3.9")
8824
def precommit(session: Session) -> None:
8925
"""Lint using pre-commit."""
9026
args = session.posargs or ["run", "--all-files", "--show-diff-on-failure"]
91-
session.install(
92-
"black",
93-
"darglint",
94-
"flake8",
95-
"flake8-bandit",
96-
"flake8-bugbear",
97-
"flake8-docstrings",
98-
"flake8-rst-docstrings",
99-
"flake8-type-checking",
100-
"pep8-naming",
101-
"pre-commit",
102-
"pre-commit-hooks",
103-
"reorder-python-imports",
104-
)
27+
session.install("-r", "requirements-lint.txt")
10528
session.run("pre-commit", *args)
106-
if args and args[0] == "install":
107-
activate_virtualenv_in_precommit_hooks(session)
108-
109-
110-
@session(python="3.9")
111-
def safety(session: Session) -> None:
112-
"""Scan dependencies for insecure packages."""
113-
requirements = session.poetry.export_requirements()
114-
session.install("safety")
115-
session.run(
116-
"safety",
117-
"check",
118-
# "--full-report",
119-
# Using --output bare below because otherwise safety is too verbose.
120-
# Unfortunately it means that any failure message is not shown so
121-
# comment these lines oput if safety fails.
122-
"--output",
123-
"bare",
124-
f"--file={requirements}",
125-
"--ignore=51457", # https://github.com/pytest-dev/py/issues/287
126-
"--ignore=58755", # https://github.com/mpmath/mpmath/issues/548
127-
)
12829

12930

13031
@session(python="3.9")
@@ -141,8 +42,7 @@ def mypy(session: Session) -> None:
14142
@session(python=python_versions)
14243
def tests(session: Session) -> None:
14344
"""Run the test suite."""
144-
session.install(".", "sympy", "llvmlite", "numpy")
145-
session.install("coverage[toml]", "pytest", "pygments")
45+
session.install(".", "-r", "requirements-test.txt")
14646
try:
14747
session.run("coverage", "run", "--parallel", "-m", "pytest", *session.posargs)
14848
finally:
@@ -163,33 +63,19 @@ def coverage(session: Session) -> None:
16363
session.run("coverage", *args)
16464

16565

166-
# It seems that with typeguard it is not possible to use if TYPE_CHECKING
167-
# blocks and all types in annotations need to be resolvable at runtime. For now
168-
# we disable this runtime type checking feature.
169-
#
170-
# @session(python=python_versions)
171-
# def typeguard(session: Session) -> None:
172-
# """Runtime type checking using Typeguard."""
173-
# session.install(".")
174-
# session.install("pytest", "typeguard", "pygments")
175-
# session.run("pytest", f"--typeguard-packages={package}", *session.posargs)
176-
177-
17866
@session(python=python_versions)
179-
def xdoctest(session: Session) -> None:
67+
def doctest(session: Session) -> None:
18068
"""Run examples with xdoctest."""
18169
args = session.posargs or ["all"]
182-
session.install(".", "sympy", "llvmlite", "numpy")
183-
session.install("xdoctest[colors]")
70+
session.install(".", "-r", "requirements-test.txt")
18471
session.run("python", "-m", "xdoctest", "--quiet", package, *args)
18572

18673

18774
@session(name="docs-build", python="3.9")
18875
def docs_build(session: Session) -> None:
18976
"""Build the documentation."""
19077
args = session.posargs or ["-W", "docs", "docs/_build"]
191-
session.install(".")
192-
session.install("sphinx", "sphinx-rtd-theme")
78+
session.install(".", "-r", "requirements-docs.txt")
19379

19480
build_dir = Path("docs", "_build")
19581
if build_dir.exists():
@@ -202,8 +88,7 @@ def docs_build(session: Session) -> None:
20288
def docs(session: Session) -> None:
20389
"""Build and serve the documentation with live reloading on file changes."""
20490
args = session.posargs or ["--open-browser", "docs", "docs/_build", "--watch=src"]
205-
session.install(".")
206-
session.install("sphinx", "sphinx-autobuild", "sphinx-rtd-theme")
91+
session.install(".", "-r", "requirements-docs.txt")
20792

20893
build_dir = Path("docs", "_build")
20994
if build_dir.exists():

quicktest.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ if [ "$1" = "--rs" ]; then
1414
cd -
1515
fi
1616

17-
poetry run pre-commit run --all-files
18-
poetry run mypy src tests
19-
poetry run python -m xdoctest --quiet protosym
20-
poetry run pytest --cov=protosym
21-
poetry run coverage html
17+
pre-commit run --all-files
18+
mypy src tests
19+
python -m xdoctest --quiet protosym
20+
pytest --cov=protosym
21+
coverage html

requirements-all.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-r requirements-lint.txt
2+
-r requirements-test.txt
3+
-r requirements-docs.txt
4+
mypy

requirements-docs.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sphinx
2+
sphinx-rtd-theme
3+
sphinx-autobuild

requirements-lint.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
black
2+
darglint
3+
flake8
4+
flake8-bandit
5+
flake8-bugbear
6+
flake8-docstrings
7+
flake8-rst-docstrings
8+
flake8-type-checking
9+
pep8-naming
10+
pre-commit
11+
pre-commit-hooks
12+
reorder-python-imports

requirements-test.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
sympy
2+
llvmlite
3+
numpy
4+
pytest
5+
coverage[toml]
6+
pygments
7+
xdoctest[colors]

src/protosym/core/tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ def topological_sort(
241241
Tree: The expression class that this function operates on.
242242
topological_split: Splits the sort into atoms, heads and nodes.
243243
"""
244+
244245
#
245246
# We use a stack here rather than recursion so that there is no limit on
246247
# the recursion depth. Otherwise though this is really just the same as
@@ -459,7 +460,6 @@ class SubsFunc:
459460
operations: list[list[int]]
460461

461462
def __new__(cls, expr: Tree, args: list[Tree]) -> SubsFunc:
462-
463463
# A topological sort but exluding the args because they will be
464464
# replaced in the substitution anyway.
465465
subexpressions = topological_sort(expr, heads=True, exclude=set(args))

0 commit comments

Comments
 (0)