Skip to content

Commit 1df78b9

Browse files
authored
cruft: update template (#50)
* cruft: update template * gha: temporarily disable tests on py3.12
1 parent 4509449 commit 1df78b9

12 files changed

+132
-198
lines changed

.cruft.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/iterative/cookiecutter-dvc-plugin",
3-
"commit": "91159828cdce86290b97bf4985732651805523c4",
3+
"commit": "da6f5faa767006bd66ed6164e9c573bc098cb346",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {

.github/workflows/release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fetch-depth: 0
2121
- uses: actions/setup-python@v3
2222
with:
23-
python-version: 3.8
23+
python-version: 3.9
2424
- name: Install
2525
run: |
2626
pip install --upgrade pip wheel

.github/workflows/tests.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
os: [ubuntu-20.04, windows-latest, macos-latest]
26-
pyv: ["3.8", "3.9", "3.10", "3.11"]
26+
# NOTE: 3.12 is temporarily disabled waiting for
27+
# https://github.com/fsspec/universal_pathlib/pull/152
28+
pyv: ["3.9", "3.10", "3.11"]
2729
steps:
2830
- uses: actions/checkout@v3
2931
with:

.pre-commit-config.yaml

+6-25
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ repos:
99
language: fail
1010
files: \.rej$
1111
repo: local
12-
- hooks:
13-
- id: black
14-
language_version: python3
15-
repo: https://github.com/ambv/black
16-
rev: 22.3.0
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: 'v0.2.0'
14+
hooks:
15+
- id: ruff
16+
args: [--fix, --exit-non-zero-on-fix]
17+
- id: ruff-format
1718
- repo: https://github.com/pre-commit/pre-commit-hooks
1819
rev: v4.0.1
1920
hooks:
@@ -26,21 +27,6 @@ repos:
2627
- ba,datas,fo,uptodate
2728
repo: https://github.com/codespell-project/codespell
2829
rev: v2.1.0
29-
- hooks:
30-
- id: isort
31-
language_version: python3
32-
repo: https://github.com/timothycrosley/isort
33-
rev: 5.12.0
34-
- hooks:
35-
- id: flake8
36-
language_version: python3
37-
additional_dependencies:
38-
- flake8-bugbear
39-
- flake8-comprehensions
40-
- flake8-debugger
41-
- flake8-string-format
42-
repo: https://github.com/pycqa/flake8
43-
rev: 3.9.2
4430
- repo: local
4531
hooks:
4632
- id: mypy
@@ -49,11 +35,6 @@ repos:
4935
files: ^dvc_gs/
5036
language: system
5137
types: [python]
52-
- id: pylint
53-
name: pylint
54-
entry: pylint
55-
language: system
56-
types: [python]
5738
- hooks:
5839
- args:
5940
- -i

dvc_gs/__init__.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
import threading
2-
from typing import Iterator, List, Optional, Tuple, Union
2+
from collections.abc import Iterator
3+
from typing import ClassVar, Optional, Union
34
from urllib.parse import urlsplit, urlunsplit
45

6+
from funcy import wrap_prop
7+
58
# pylint:disable=abstract-method
69
from dvc.utils.objects import cached_property
710
from dvc_objects.fs.base import AnyFSPath, ObjectFileSystem
8-
from funcy import wrap_prop
911

1012

1113
class GSFileSystem(ObjectFileSystem):
1214
protocol = "gs"
13-
REQUIRES = {"gcsfs": "gcsfs"}
15+
REQUIRES: ClassVar[dict[str, str]] = {"gcsfs": "gcsfs"}
1416
PARAM_CHECKSUM = "etag"
1517

1618
def getcwd(self):
1719
return self.fs.root_marker
1820

1921
@classmethod
20-
def split_version(cls, path: AnyFSPath) -> Tuple[str, Optional[str]]:
22+
def split_version(cls, path: AnyFSPath) -> tuple[str, Optional[str]]:
2123
from gcsfs import GCSFileSystem
2224

2325
parts = list(urlsplit(path))
@@ -49,13 +51,11 @@ def version_path(cls, path: AnyFSPath, version_id: Optional[str]) -> str:
4951
@classmethod
5052
def coalesce_version(
5153
cls, path: AnyFSPath, version_id: Optional[str]
52-
) -> Tuple[AnyFSPath, Optional[str]]:
54+
) -> tuple[AnyFSPath, Optional[str]]:
5355
path, path_version_id = cls.split_version(path)
5456
versions = {ver for ver in (version_id, path_version_id) if ver}
5557
if len(versions) > 1:
56-
raise ValueError(
57-
f"Path version mismatch: '{path}', '{version_id}'"
58-
)
58+
raise ValueError(f"Path version mismatch: '{path}', '{version_id}'")
5959
return path, (versions.pop() if versions else None)
6060

6161
def _prepare_credentials(self, **config):
@@ -99,7 +99,7 @@ def _get_kwargs_from_urls(urlpath: str):
9999

100100
def find(
101101
self,
102-
path: Union[AnyFSPath, List[AnyFSPath]],
102+
path: Union[AnyFSPath, list[AnyFSPath]],
103103
prefix: bool = False,
104104
batch_size: Optional[int] = None, # pylint: disable=unused-argument
105105
**kwargs,
@@ -115,6 +115,4 @@ def _add_dir_sep(path: str) -> str:
115115
path = _add_dir_sep(path)
116116
else:
117117
path = [_add_dir_sep(p) for p in path]
118-
return super().find(
119-
path, prefix=prefix, batch_size=batch_size, **kwargs
120-
)
118+
return super().find(path, prefix=prefix, batch_size=batch_size, **kwargs)

dvc_gs/tests/benchmarks.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
# pylint: disable=unused-import
2-
# noqa
3-
from dvc.testing.benchmarks.cli.stories.use_cases.test_sharing import ( # noqa
4-
test_sharing as test_sharing_gs,
5-
)

dvc_gs/tests/cloud.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
class GCP(Cloud, CloudURLInfo):
9-
109
IS_OBJECT_STORAGE = True
1110

1211
def __init__(self, url, credentialpath):
@@ -101,7 +100,8 @@ class FakeGCP(GCP):
101100

102101
def __init__(self, url, endpoint_url: str):
103102
super().__init__(
104-
url, "" # no need to provide credentials for a mock server
103+
url,
104+
"", # no need to provide credentials for a mock server
105105
)
106106
self.endpoint_url = endpoint_url
107107

dvc_gs/tests/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from dvc.testing.fixtures import * # noqa, pylint: disable=wildcard-import,unused-import
1+
from dvc.testing.fixtures import * # noqa: F403
22

3-
from .fixtures import * # noqa, pylint: disable=wildcard-import,unused-import
3+
from .fixtures import * # noqa: F403

dvc_gs/tests/fixtures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ def gs(make_gs): # pylint: disable=redefined-outer-name
4242

4343
@pytest.fixture
4444
def real_gs():
45-
yield GCP(GCP.get_url(), "")
45+
return GCP(GCP.get_url(), "")

dvc_gs/tests/test_dvc.py

+7-22
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,31 @@
11
import pytest
2-
from dvc.testing.api_tests import ( # noqa, pylint: disable=unused-import
3-
TestAPI,
4-
)
5-
from dvc.testing.remote_tests import ( # noqa, pylint: disable=unused-import
6-
TestRemote,
7-
TestRemoteVersionAware,
8-
)
9-
from dvc.testing.workspace_tests import ( # noqa, pylint: disable=unused-import
10-
TestGetUrl,
11-
)
2+
123
from dvc.testing.workspace_tests import TestImport as _TestImport
13-
from dvc.testing.workspace_tests import ( # noqa, pylint: disable=unused-import
14-
TestImportURLVersionAware,
15-
TestLsUrl,
16-
)
174

185

196
@pytest.fixture
207
def cloud(make_cloud):
21-
yield make_cloud(typ="gs")
8+
return make_cloud(typ="gs")
229

2310

2411
@pytest.fixture
2512
def remote(make_remote):
26-
yield make_remote(name="upstream", typ="gs")
13+
return make_remote(name="upstream", typ="gs")
2714

2815

2916
@pytest.fixture
3017
def remote_version_aware(make_remote_version_aware):
31-
yield make_remote_version_aware(name="upstream", typ="gs")
18+
return make_remote_version_aware(name="upstream", typ="gs")
3219

3320

3421
@pytest.fixture
3522
def remote_worktree(make_remote_worktree):
36-
yield make_remote_worktree(name="upstream", typ="gs")
23+
return make_remote_worktree(name="upstream", typ="gs")
3724

3825

3926
@pytest.fixture
4027
def workspace(make_workspace):
41-
yield make_workspace(name="workspace", typ="gs")
28+
return make_workspace(name="workspace", typ="gs")
4229

4330

4431
class TestImport(_TestImport):
@@ -66,6 +53,4 @@ def test_import_empty_dir(
6653
workspace, # pylint: disable=redefined-outer-name
6754
is_object_storage,
6855
):
69-
return super().test_import_empty_dir(
70-
tmp_dir, dvc, workspace, is_object_storage
71-
)
56+
return super().test_import_empty_dir(tmp_dir, dvc, workspace, is_object_storage)

pyproject.toml

+99-44
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,65 @@ build-backend = "setuptools.build_meta"
55
[tool.setuptools_scm]
66
write_to = "dvc_gs/_dvc_gs_version.py"
77

8-
[tool.black]
9-
line-length = 79
10-
include = '\.pyi?$'
11-
exclude = '''
12-
/(
13-
\.eggs
14-
| \.git
15-
| \.hg
16-
| \.mypy_cache
17-
| \.tox
18-
| \.venv
19-
| _build
20-
| buck-out
21-
| build
22-
| dist
23-
)/
24-
'''
25-
26-
[tool.isort]
27-
profile = "black"
28-
known_first_party = ["dvc_gs"]
29-
line_length = 79
8+
[project]
9+
name = "dvc-gs"
10+
description = "gs plugin for dvc"
11+
readme = "README.rst"
12+
keywords = [
13+
"dvc",
14+
"gs",
15+
]
16+
license = { text = "Apache License 2.0" }
17+
maintainers = [{ name = "Iterative", email = "[email protected]" }]
18+
authors = [{ name = "Iterative", email = "[email protected]" }]
19+
requires-python = ">=3.9"
20+
classifiers = [
21+
"Development Status :: 4 - Beta",
22+
"Programming Language :: Python :: 3",
23+
"Programming Language :: Python :: 3.9",
24+
"Programming Language :: Python :: 3.10",
25+
"Programming Language :: Python :: 3.11",
26+
"Programming Language :: Python :: 3.12",
27+
]
28+
dynamic = ["version"]
29+
dependencies = [
30+
"dvc",
31+
"gcsfs>=2022.11.0",
32+
]
33+
34+
[project.optional-dependencies]
35+
tests = [
36+
"wheel==0.37.0",
37+
"dvc[testing]",
38+
# Test requirements
39+
"pytest==7.1.2",
40+
"pytest-cov==3.0.0",
41+
"pytest-xdist==2.4.0",
42+
"pytest-mock==3.6.1",
43+
"pytest-lazy-fixture==0.6.3",
44+
"pytest-servers[gcs]>=0.3.0",
45+
"flaky==3.7.0",
46+
"mock==4.0.3",
47+
"wget==3.2",
48+
"filelock==3.3.2",
49+
"xmltodict==0.12.0",
50+
# required by collective.checkdocs
51+
"Pygments==2.10.0",
52+
"collective.checkdocs==0.2",
53+
"pydocstyle==6.1.1",
54+
# type-checking
55+
"mypy==0.981",
56+
"types-requests==2.25.11",
57+
"types-tabulate==0.8.3",
58+
"types-toml==0.10.1",
59+
# optional dependencies
60+
'pywin32>=225; sys_platform == "win32"',
61+
"google-cloud-storage>=2.7.0",
62+
]
63+
64+
[project.urls]
65+
Documentation = "https://dvc.org/doc"
66+
Source = "https://github.com/iterative/dvc-gs"
3067

3168
[tool.pytest.ini_options]
3269
log_level = "debug"
@@ -51,28 +88,46 @@ warn_redundant_casts = true
5188
warn_unreachable = true
5289
files = ["dvc_gs"]
5390

54-
[tool.pylint.master]
55-
extension-pkg-whitelist = ["pygit2"]
56-
init-hook = "import sys; sys.path.append(str('tests'))"
57-
58-
[tool.pylint.message_control]
59-
disable = [
60-
"format", "refactoring", "spelling", "design",
61-
"invalid-name", "duplicate-code", "fixme",
62-
"unused-wildcard-import", "cyclic-import", "wrong-import-order",
63-
"wrong-import-position", "ungrouped-imports", "multiple-imports",
64-
"logging-format-interpolation", "logging-fstring-interpolation",
65-
"missing-function-docstring", "missing-module-docstring",
66-
"missing-class-docstring", "raise-missing-from", "import-outside-toplevel",
91+
[tool.ruff]
92+
output-format = "full"
93+
show-fixes = true
94+
95+
[tool.ruff.lint]
96+
ignore = [
97+
"N818", "S101", "ISC001", "PT004", "PT007", "RET502", "RET503", "SIM105", "SIM108", "SIM117",
98+
"TRY003", "TRY300", "PLR2004", "PLW2901", "LOG007",
6799
]
68-
enable = ["c-extension-no-member", "no-else-return"]
100+
select = [
101+
"F", "E", "W", "C90", "I", "N", "UP", "YTT", "ASYNC", "S", "BLE", "B", "A", "C4", "T10",
102+
"EXE", "ISC", "ICN", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET",
103+
"SLOT", "SIM", "TID", "TCH", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY",
104+
"FLY", "PERF101", "LOG", "RUF", "RUF022", "RUF023", "RUF024", "RUF025", "RUF026",
105+
]
106+
preview = true
107+
explicit-preview-rules = true
108+
109+
[tool.ruff.lint.flake8-pytest-style]
110+
fixture-parentheses = false
111+
mark-parentheses = false
112+
parametrize-names-type = "csv"
113+
raises-extend-require-match-for = ["dvc.exceptions.DvcException"]
114+
115+
[tool.ruff.lint.flake8-tidy-imports]
116+
117+
[tool.ruff.lint.flake8-type-checking]
118+
strict = true
119+
120+
[tool.ruff.lint.flake8-unused-arguments]
121+
ignore-variadic-names = true
122+
123+
[tool.ruff.lint.isort]
124+
known-first-party = ["dvc", "dvc_data", "dvc_objects"]
125+
126+
[tool.ruff.lint.pep8-naming]
127+
extend-ignore-names = ["M", "SCM"]
69128

70-
[tool.pylint.typecheck]
71-
generated-members = ["pytest.lazy_fixture", "logging.TRACE", "logger.trace", "sys.getwindowsversion", "argparse.Namespace"]
72-
ignored-classes = ["Dvcfile"]
73-
ignored-modules = ["azure"]
74-
signature-mutators = ["funcy.decorators.decorator"]
129+
[tool.ruff.lint.pylint]
130+
max-args = 10
75131

76-
[tool.pylint.variables]
77-
dummy-variables-rgx = "_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_"
78-
ignored-argument-names = "_.*|^ignored_|^unused_|args|kwargs"
132+
[tool.ruff.lint.per-file-ignores]
133+
"dvc_gs/tests/**" = ["S", "ARG001", "ARG002", "TRY002", "TRY301"]

0 commit comments

Comments
 (0)