Skip to content

Commit 61ee409

Browse files
github-actions[bot]daavoodberenbaumdberenbaum
authored
update template (#144)
* update template * fix pyproject.toml * fix linting * update deps and drop setup.cfg * fix mypy import error * fix tests * drop tmp_dir fixture from dvc --------- Co-authored-by: daavoo <daavoo@users.noreply.github.com> Co-authored-by: dberenbaum <dave@iterative.ai> Co-authored-by: Dave Berenbaum <dave.berenbaum@gmail.com>
1 parent f3c3f66 commit 61ee409

20 files changed

+261
-331
lines changed

.cruft.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/iterative/py-template",
3-
"commit": "0aac03d10cbc7b2f7e144e728de5043b7a3458cb",
3+
"commit": "15ee26df315020399731c6291d61bef81a3fc5d3",
44
"context": {
55
"cookiecutter": {
66
"project_name": "dvc-render",

.pre-commit-config.yaml

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
default_language_version:
22
python: python3
33
repos:
4-
- repo: https://github.com/psf/black
5-
rev: 23.9.1
6-
hooks:
7-
- id: black
84
- repo: https://github.com/pre-commit/pre-commit-hooks
9-
rev: v4.4.0
5+
rev: v4.5.0
106
hooks:
117
- id: check-added-large-files
128
- id: check-case-conflict
@@ -23,32 +19,14 @@ repos:
2319
args: ['--fix=lf']
2420
- id: sort-simple-yaml
2521
- id: trailing-whitespace
22+
- repo: https://github.com/astral-sh/ruff-pre-commit
23+
rev: 'v0.1.7'
24+
hooks:
25+
- id: ruff
26+
args: [--fix, --exit-non-zero-on-fix]
27+
- id: ruff-format
2628
- repo: https://github.com/codespell-project/codespell
27-
rev: v2.2.5
29+
rev: v2.2.6
2830
hooks:
2931
- id: codespell
3032
additional_dependencies: ["tomli"]
31-
- repo: https://github.com/asottile/pyupgrade
32-
rev: v3.10.1
33-
hooks:
34-
- id: pyupgrade
35-
args: [--py38-plus]
36-
- repo: https://github.com/PyCQA/isort
37-
rev: 5.12.0
38-
hooks:
39-
- id: isort
40-
- repo: https://github.com/pycqa/flake8
41-
rev: 6.1.0
42-
hooks:
43-
- id: flake8
44-
additional_dependencies:
45-
- flake8-bugbear==23.7.10
46-
- flake8-comprehensions==3.14.0
47-
- flake8-debugger==4.1.2
48-
- flake8-string-format==0.3.0
49-
- repo: https://github.com/pycqa/bandit
50-
rev: 1.7.5
51-
hooks:
52-
- id: bandit
53-
args: [-c, pyproject.toml]
54-
additional_dependencies: [".[toml]"]

noxfile.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def lint(session: nox.Session) -> None:
3535
args = *(session.posargs or ("--show-diff-on-failure",)), "--all-files"
3636
session.run("pre-commit", "run", *args)
3737
session.run("python", "-m", "mypy")
38-
session.run("python", "-m", "pylint", *locations)
3938

4039

4140
@nox.session

pyproject.toml

Lines changed: 87 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,63 @@ build-backend = "setuptools.build_meta"
44

55
[tool.setuptools_scm]
66

7-
[tool.black]
8-
line-length = 88
9-
include = '\.pyi?$'
10-
exclude = '''
11-
/(
12-
\.eggs
13-
| \.git
14-
| \.hg
15-
| \.mypy_cache
16-
| \.tox
17-
| \.venv
18-
| _build
19-
| buck-out
20-
| build
21-
| dist
22-
)/
23-
'''
24-
25-
[tool.isort]
26-
profile = "black"
27-
known_first_party = ["dvc_render"]
28-
line_length = 88
7+
[project]
8+
name = "dvc-render"
9+
description = "Dvc Render"
10+
readme = "README.rst"
11+
license = {text = "Apache-2.0"}
12+
authors = [{ name = "Iterative", email = "support@dvc.org" }]
13+
classifiers = [
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: Python :: 3.8",
16+
"Programming Language :: Python :: 3.9",
17+
"Programming Language :: Python :: 3.10",
18+
"Programming Language :: Python :: 3.11",
19+
"Development Status :: 4 - Beta",
20+
]
21+
requires-python = ">=3.8"
22+
dynamic = ["version"]
23+
dependencies = []
24+
25+
[project.urls]
26+
Issues = "https://github.com/iterative/dvc-render/issues"
27+
Source = "https://github.com/iterative/dvc-render"
28+
29+
[project.optional-dependencies]
30+
table = [
31+
"tabulate>=0.8.7",
32+
"flatten_dict<1,>=0.4.1",
33+
]
34+
markdown = [
35+
"dvc-render[table]",
36+
"matplotlib",
37+
]
38+
docs = [
39+
"mkdocs==1.5.2",
40+
"mkdocs-gen-files==0.5.0",
41+
"mkdocs-material==9.3.1",
42+
"mkdocs-section-index==0.3.6",
43+
"mkdocstrings-python==1.6.3",
44+
]
45+
tests = [
46+
"dvc-render[table]",
47+
"dvc-render[markdown]",
48+
"pytest==7.2.0",
49+
"pytest-sugar==0.9.5",
50+
"pytest-cov==3.0.0",
51+
"pytest-mock==3.8.2",
52+
"mypy==1.2.0",
53+
]
54+
dev = [
55+
"dvc-render[table]",
56+
"dvc-render[markdown]",
57+
"dvc-render[tests]",
58+
"dvc-render[docs]",
59+
]
60+
61+
[tool.setuptools.packages.find]
62+
where = ["src"]
63+
namespaces = false
2964

3065
[tool.pytest.ini_options]
3166
addopts = "-ra"
@@ -70,27 +105,38 @@ module = [
70105
]
71106
ignore_missing_imports = true
72107

108+
[tool.codespell]
109+
ignore-words-list = " "
73110

74-
[tool.pylint.format]
75-
max-line-length = 88
76-
77-
[tool.pylint.message_control]
78-
enable = ["c-extension-no-member", "no-else-return"]
79-
disable = [
80-
"missing-module-docstring",
81-
"missing-class-docstring",
82-
"invalid-name",
83-
"R0801",
84-
"C0415"
111+
[tool.ruff]
112+
ignore = [
113+
"S101", # assert
114+
"PLR2004", # magic-value-comparison
115+
"PLW2901", # redefined-loop-name
116+
"ISC001", # single-line-implicit-string-concatenation
117+
"SIM105", # suppressible-exception
118+
"SIM108", # if-else-block-instead-of-if-exp
119+
"D203", # one blank line before class
120+
"D213", # multi-line-summary-second-line
121+
"RUF012", # mutable class attributes
122+
"PT007", # value types in pytest.mark.parametrize
85123
]
124+
select = [
125+
"F", "E", "W", "C90", "I", "N", "UP", "YTT", "ASYNC", "S", "BLE", "B", "A", "C4", "T10",
126+
"EXE", "ISC", "ICN", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET",
127+
"SLOT", "SIM", "TID", "TCH", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY",
128+
"FLY", "PERF101", "RUF",
129+
]
130+
show-source = true
131+
show-fixes = true
86132

87-
[tool.pylint.variables]
88-
dummy-variables-rgx = "_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_"
89-
ignored-argument-names = "_.*|^ignored_|^unused_|args|kwargs"
133+
[tool.ruff.per-file-ignores]
134+
"noxfile.py" = ["D", "PTH"]
135+
"tests/**" = ["S", "ARG001", "ARG002", "ANN"]
136+
"docs/**" = ["INP"]
90137

91-
[tool.codespell]
92-
ignore-words-list = " "
138+
[tool.ruff.lint.flake8-type-checking]
139+
strict = true
93140

94-
[tool.bandit]
95-
exclude_dirs = ["tests"]
96-
skips = ["B101"]
141+
[tool.ruff.lint.isort]
142+
known-first-party = ["{{ cookiecutter.package_name }}"]

setup.cfg

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/dvc_render/base.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ class Renderer(abc.ABC):
1919

2020
EXTENSIONS: Iterable[str] = {}
2121

22-
def __init__(self, datapoints: List = None, name: str = None, **properties):
22+
def __init__(
23+
self,
24+
datapoints: Optional[List] = None,
25+
name: Optional[str] = None,
26+
**properties,
27+
):
2328
self.datapoints = datapoints or []
2429
self.name = name or ""
2530
self.properties = properties
@@ -34,12 +39,12 @@ def partial_html(self, **kwargs) -> str:
3439

3540
@property
3641
@abc.abstractmethod
37-
def TYPE(self): # pylint: disable=missing-function-docstring
42+
def TYPE(self): # noqa: N802
3843
raise NotImplementedError
3944

4045
@property
4146
@abc.abstractmethod
42-
def SCRIPTS(self): # pylint: disable=missing-function-docstring
47+
def SCRIPTS(self): # noqa: N802
4348
raise NotImplementedError
4449

4550
@staticmethod
@@ -58,13 +63,11 @@ def generate_html(self, html_path=None) -> str:
5863
return self.DIV.format(id=div_id, partial=partial)
5964
return ""
6065

61-
def generate_markdown(
62-
self, report_path: Optional[StrPath] = None
63-
) -> str: # pylint: disable=missing-function-docstring
66+
def generate_markdown(self, report_path: Optional[StrPath] = None) -> str: # pylint: disable=missing-function-docstring
6467
"Generate a markdown element"
6568
raise NotImplementedError
6669

6770
@classmethod
68-
def matches(cls, filename, properties) -> bool: # pylint: disable=unused-argument
71+
def matches(cls, filename) -> bool: # pylint: disable=unused-argument
6972
"Check if the Renderer is suitable."
7073
return Path(filename).suffix in cls.EXTENSIONS

src/dvc_render/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
class DvcRenderException(Exception):
1+
class DvcRenderError(Exception):
22
pass
33

44

5-
class MissingPlaceholderError(DvcRenderException):
5+
class MissingPlaceholderError(DvcRenderError):
66
def __init__(self, placeholder, template_type):
77
super().__init__(f"{template_type} template has to contain '{placeholder}'.")

src/dvc_render/html.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from dvc_render.image import ImageRenderer
66

7-
from .exceptions import DvcRenderException
7+
from .exceptions import DvcRenderError
88

99
if TYPE_CHECKING:
1010
from .base import Renderer, StrPath
@@ -28,7 +28,7 @@
2828
</html>"""
2929

3030

31-
class MissingPlaceholderError(DvcRenderException):
31+
class MissingPlaceholderError(DvcRenderError):
3232
def __init__(self, placeholder):
3333
super().__init__(f"HTML template has to contain '{placeholder}'.")
3434

src/dvc_render/image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ImageRenderer(Renderer):
2222

2323
EXTENSIONS = {".jpg", ".jpeg", ".gif", ".png", ".svg"}
2424

25-
def partial_html(self, html_path=None, **kwargs) -> str:
25+
def partial_html(self, html_path=None, **kwargs) -> str: # noqa: ARG002
2626
div_content = []
2727
for datapoint in self.datapoints:
2828
src = datapoint[self.SRC_FIELD]
@@ -50,7 +50,7 @@ def partial_html(self, html_path=None, **kwargs) -> str:
5050
return "\n".join(div_content)
5151
return ""
5252

53-
def generate_markdown(self, report_path=None) -> str:
53+
def generate_markdown(self) -> str: # type: ignore[override]
5454
content = []
5555
for datapoint in self.datapoints:
5656
src = datapoint[self.SRC_FIELD]

src/dvc_render/plotly.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(
4242
self.name = name
4343
self.fill_value = fill_value
4444

45-
def partial_html(self, **kwargs) -> str:
45+
def partial_html(self, **kwargs) -> str: # noqa: ARG002
4646
return json.dumps(self._get_plotly_data())
4747

4848
def _get_plotly_data(self):

0 commit comments

Comments
 (0)