Skip to content

Commit b1d0507

Browse files
authored
remove setup.cfg file (#874)
* remove setup.cfg file * improve warning stack level + fix minor issue * fix docker file * use COPY instead of ADD in docker this is recommended by docker: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy
1 parent 0894df2 commit b1d0507

File tree

7 files changed

+98
-89
lines changed

7 files changed

+98
-89
lines changed

docs/Dockerfile

+14-14
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@ RUN pip install --upgrade pip
1717

1818
# Install IDOM
1919
# ------------
20-
ADD requirements ./requirements
20+
COPY requirements ./requirements
2121
RUN pip install -r requirements/build-docs.txt
2222

23-
ADD src ./src
24-
ADD scripts ./scripts
25-
ADD setup.py ./
26-
ADD setup.cfg ./
27-
ADD MANIFEST.in ./
28-
ADD README.md ./
23+
COPY src ./src
24+
COPY scripts ./scripts
25+
COPY setup.py ./
26+
COPY pyproject.toml ./
27+
COPY MANIFEST.in ./
28+
COPY README.md ./
2929
RUN pip install -e .[all]
3030

31-
# Add License
31+
# COPY License
3232
# -----------
33-
Add LICENSE /app/
33+
COPY LICENSE /app/
3434

3535
# Build the Docs
3636
# --------------
37-
ADD docs/__init__.py ./docs/
38-
ADD docs/app.py ./docs/
39-
ADD docs/examples.py ./docs/
40-
ADD docs/source ./docs/source
41-
ADD branding ./branding
37+
COPY docs/__init__.py ./docs/
38+
COPY docs/app.py ./docs/
39+
COPY docs/examples.py ./docs/
40+
COPY docs/source ./docs/source
41+
COPY branding ./branding
4242
RUN sphinx-build -v -W -b html docs/source docs/build
4343

4444
# Define Entrypoint

noxfile.py

+12-15
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,21 @@ def test_python_suite(session: Session) -> None:
180180
session.env["IDOM_DEBUG_MODE"] = "1"
181181
install_requirements_file(session, "test-env")
182182
session.run("playwright", "install", "chromium")
183-
posargs = session.posargs
184-
posargs += ["--reruns", "3", "--reruns-delay", "1"]
183+
args = ["pytest", "--reruns", "3", "--reruns-delay", "1", *session.posargs]
185184

186-
if "--no-cov" in session.posargs:
185+
check_cov = "--no-cov" not in session.posargs
186+
if check_cov:
187+
args = ["coverage", "run", "--source=src/idom", "--module", *args]
188+
install_idom_dev(session)
189+
else:
190+
args.remove("--no-cov")
187191
session.log("Coverage won't be checked")
188192
session.install(".[all]")
189-
else:
190-
posargs += ["--cov=src/idom", "--cov-report", "term"]
191-
install_idom_dev(session)
192193

193-
session.run("pytest", *posargs)
194+
session.run(*args)
195+
196+
if check_cov:
197+
session.run("coverage", "report")
194198

195199

196200
@nox.session
@@ -209,14 +213,7 @@ def test_python_style(session: Session) -> None:
209213
"""Check that Python style guidelines are being followed"""
210214
install_requirements_file(session, "check-style")
211215
session.run("flake8", "src/idom", "tests", "docs")
212-
black_default_exclude = r"\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist"
213-
session.run(
214-
"black",
215-
".",
216-
"--check",
217-
"--exclude",
218-
rf"/({black_default_exclude}|venv|node_modules)/",
219-
)
216+
session.run("black", ".", "--check")
220217
session.run("isort", ".", "--check-only")
221218

222219

pyproject.toml

+43
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,46 @@ ensure_newline_before_comments = "True"
1010
include_trailing_comma = "True"
1111
line_length = 88
1212
lines_after_imports = 2
13+
14+
[tool.mypy]
15+
ignore_missing_imports = true
16+
warn_unused_configs = true
17+
warn_redundant_casts = true
18+
warn_unused_ignores = true
19+
20+
[tool.pytest.ini_options]
21+
testpaths = "tests"
22+
xfail_strict = true
23+
markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"]
24+
python_files = "*asserts.py test_*.py"
25+
asyncio_mode = "auto"
26+
27+
[tool.coverage.report]
28+
fail_under = 100
29+
show_missing = true
30+
skip_covered = true
31+
sort = "Name"
32+
exclude_lines = [
33+
"pragma: no cover",
34+
'\.\.\.',
35+
"raise NotImplementedError",
36+
]
37+
38+
[tool.pydocstyle]
39+
inherit = false
40+
match = '.*\.py'
41+
convention = "google"
42+
add_ignore = ["D100", "D101", "D102", "D103", "D104", "D105", "D107", "D412", "D415"]
43+
44+
[tool.flake8]
45+
ignore = ["E203", "E266", "E501", "W503", "F811", "N802", "N806"]
46+
per-file-ignores = [
47+
# sometimes this is required in order to hide setup for an example
48+
"docs/*/_examples/*.py:E402",
49+
]
50+
max-line-length = 88
51+
max-complexity = 18
52+
select = ["B", "C", "E", "F", "W", "T4", "B9", "N", "ROH"]
53+
exclude = ["**/node_modules/*", ".eggs/*", ".tox/*"]
54+
# -- flake8-tidy-imports --
55+
ban-relative-imports = "parents"

requirements/check-style.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
black
1+
black[jupyter]
22
flake8
3+
flake8-pyproject
34
flake8-idom-hooks >=0.5.0
45
flake8-print
56
flake8-tidy-imports

requirements/test-env.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
pytest
22
pytest-asyncio>=0.17
3-
pytest-cov
43
pytest-mock
54
pytest-rerunfailures
65
pytest-timeout
6+
7+
coverage
78
responses
89
playwright
910

setup.cfg

-55
This file was deleted.

src/idom/_option.py

+25-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from __future__ import annotations
22

33
import os
4-
import warnings
4+
from inspect import currentframe
55
from logging import getLogger
6-
from typing import Any, Callable, Generic, TypeVar, cast
6+
from types import FrameType
7+
from typing import Any, Callable, Generic, Iterator, TypeVar, cast
8+
from warnings import warn
79

810

911
_O = TypeVar("_O")
@@ -129,12 +131,32 @@ def __init__(self, new_opt: Option[_O], name: str) -> None:
129131

130132
@property # type: ignore
131133
def _current(self) -> _O:
132-
warnings.warn(
134+
warn(
133135
f"{self.name!r} has been renamed to {self._new_opt.name!r}",
134136
DeprecationWarning,
137+
stacklevel=_frame_depth_in_module() + 1,
135138
)
136139
return self._new_opt.current
137140

138141
@_current.setter
139142
def _current(self, new: _O) -> None:
140143
self._new_opt.current = new
144+
145+
146+
def _frame_depth_in_module() -> int:
147+
depth = 0
148+
for frame in _iter_frames(2):
149+
if frame.f_globals.get("__name__") != __name__:
150+
break
151+
depth += 1
152+
return depth
153+
154+
155+
def _iter_frames(index: int = 1) -> Iterator[FrameType]:
156+
frame = currentframe()
157+
while frame is not None:
158+
if index == 0:
159+
yield frame
160+
else:
161+
index -= 1
162+
frame = frame.f_back

0 commit comments

Comments
 (0)