Skip to content

Commit

Permalink
cruft: update template
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Feb 3, 2024
1 parent 8d7888e commit 676ba40
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 177 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/iterative/cookiecutter-dvc-plugin",
"commit": "91159828cdce86290b97bf4985732651805523c4",
"commit": "55dea263c00d5e174aed89451c29f6b7ef0f9577",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-python@v3
with:
python-version: 3.8
python-version: 3.9
- name: Install
run: |
pip install --upgrade pip wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
pyv: ["3.8", "3.9", "3.10", "3.11"]
pyv: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand Down
31 changes: 6 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ repos:
language: fail
files: \.rej$
repo: local
- hooks:
- id: black
language_version: python3
repo: https://github.com/ambv/black
rev: 22.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.2.0'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
Expand All @@ -26,21 +27,6 @@ repos:
- ba,datas,fo,uptodate
repo: https://github.com/codespell-project/codespell
rev: v2.1.0
- hooks:
- id: isort
language_version: python3
repo: https://github.com/timothycrosley/isort
rev: 5.12.0
- hooks:
- id: flake8
language_version: python3
additional_dependencies:
- flake8-bugbear
- flake8-comprehensions
- flake8-debugger
- flake8-string-format
repo: https://github.com/pycqa/flake8
rev: 3.9.2
- repo: local
hooks:
- id: mypy
Expand All @@ -49,11 +35,6 @@ repos:
files: ^dvc_ssh/
language: system
types: [python]
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
- hooks:
- args:
- -i
Expand Down
13 changes: 6 additions & 7 deletions dvc_ssh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import getpass
import os.path
import threading
from typing import ClassVar

from funcy import memoize, silent, wrap_prop, wrap_with

from dvc.utils.objects import cached_property
from dvc_objects.fs.base import FileSystem
from dvc_objects.fs.callbacks import DEFAULT_CALLBACK
from dvc_objects.fs.utils import as_atomic
from funcy import memoize, silent, wrap_prop, wrap_with

DEFAULT_PORT = 22

Expand All @@ -16,8 +18,7 @@
def ask_password(host, user, port, desc):
try:
return getpass.getpass(
f"Enter a {desc} for "
f"host '{host}' port '{port}' user '{user}':\n"
f"Enter a {desc} for " f"host '{host}' port '{port}' user '{user}':\n"
)
except EOFError:
return None
Expand All @@ -26,7 +27,7 @@ def ask_password(host, user, port, desc):
# pylint:disable=abstract-method
class SSHFileSystem(FileSystem):
protocol = "ssh"
REQUIRES = {"sshfs": "sshfs"}
REQUIRES: ClassVar[dict[str, str]] = {"sshfs": "sshfs"}
PARAM_CHECKSUM = "md5"

@classmethod
Expand Down Expand Up @@ -84,9 +85,7 @@ def _prepare_credentials(self, **config):
raw_keys.extend(user_ssh_config.get("IdentityFile"))

if raw_keys:
login_info["client_keys"] = [
os.path.expanduser(key) for key in raw_keys
]
login_info["client_keys"] = [os.path.expanduser(key) for key in raw_keys]

login_info["timeout"] = config.get("timeout", 1800)

Expand Down
3 changes: 2 additions & 1 deletion dvc_ssh/tests/cloud.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import uuid

from funcy import cached_property

from dvc.testing.cloud import Cloud
from dvc.testing.path_info import URLInfo
from funcy import cached_property

TEST_SSH_USER = "user"
TEST_SSH_KEY_PATH = os.path.join(
Expand Down
4 changes: 2 additions & 2 deletions dvc_ssh/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from dvc.testing.fixtures import * # noqa, pylint: disable=wildcard-import,unused-import
from dvc.testing.fixtures import * # noqa: F403

from .fixtures import * # noqa, pylint: disable=wildcard-import,unused-import
from .fixtures import * # noqa: F403
2 changes: 1 addition & 1 deletion dvc_ssh/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _check():
def ssh_connection(ssh_server):
from sshfs import SSHFileSystem

yield SSHFileSystem(
return SSHFileSystem(
host=ssh_server["host"],
port=ssh_server["port"],
username=TEST_SSH_USER,
Expand Down
17 changes: 8 additions & 9 deletions dvc_ssh/tests/test_dvc.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
import pytest
from dvc.testing.api_tests import ( # noqa, pylint: disable=unused-import

from dvc.testing.api_tests import ( # noqa: F401
TestAPI,
)
from dvc.testing.remote_tests import ( # noqa, pylint: disable=unused-import
from dvc.testing.remote_tests import ( # noqa: F401
TestRemote,
)
from dvc.testing.workspace_tests import ( # noqa, pylint: disable=unused-import
from dvc.testing.workspace_tests import ( # noqa: F401 # noqa: F401
TestGetUrl,
)
from dvc.testing.workspace_tests import TestImport as _TestImport
from dvc.testing.workspace_tests import ( # noqa, pylint: disable=unused-import
TestLsUrl,
)
from dvc.testing.workspace_tests import TestImport as _TestImport


@pytest.fixture
def cloud(make_cloud):
yield make_cloud(typ="ssh")
return make_cloud(typ="ssh")


@pytest.fixture
def remote(make_remote):
yield make_remote(name="upstream", typ="ssh")
return make_remote(name="upstream", typ="ssh")


@pytest.fixture
def workspace(make_workspace):
yield make_workspace(name="workspace", typ="ssh")
return make_workspace(name="workspace", typ="ssh")


class TestImport(_TestImport):
Expand Down
142 changes: 98 additions & 44 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,64 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
write_to = "dvc_ssh/_dvc_ssh_version.py"

[tool.black]
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''

[tool.isort]
profile = "black"
known_first_party = ["dvc_ssh"]
line_length = 79
[project]
name = "dvc-ssh"
description = "ssh plugin for dvc"
readme = "README.rst"
keywords = [
"dvc",
"ssh",
]
license = { text = "Apache License 2.0" }
maintainers = [{ name = "Iterative", email = "[email protected]" }]
authors = [{ name = "Iterative", email = "[email protected]" }]
requires-python = ">=3.9"
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ["version"]
dependencies = [
"dvc",
"sshfs[bcrypt]>=2023.4.1",
]

[project.optional-dependencies]
gssapi = ["sshfs[gssapi]>=2021.11.2"]
tests = [
"wheel==0.37.0",
"dvc[testing]",
# Test requirements
"pytest==6.2.5",
"pytest-cov==3.0.0",
"pytest-xdist==2.4.0",
"pytest-mock==3.6.1",
"pytest-lazy-fixture==0.6.3",
"flaky==3.7.0",
"mock==4.0.3",
"wget==3.2",
"filelock==3.3.2",
"xmltodict==0.12.0",
# required by collective.checkdocs
"Pygments==2.10.0",
"collective.checkdocs==0.2",
"pydocstyle==6.1.1",
# type-checking
"mypy==0.981",
"types-requests==2.25.11",
"types-tabulate==0.8.3",
"types-toml==0.10.1",
# optional dependencies
'pywin32>=225; sys_platform == "win32"',
]

[project.urls]
Documentation = "https://dvc.org/doc"
Source = "https://github.com/iterative/dvc-ssh"

[tool.pytest.ini_options]
log_level = "debug"
Expand All @@ -51,28 +87,46 @@ warn_redundant_casts = true
warn_unreachable = true
files = ["dvc_ssh"]

[tool.pylint.master]
extension-pkg-whitelist = ["pygit2"]
init-hook = "import sys; sys.path.append(str('tests'))"

[tool.pylint.message_control]
disable = [
"format", "refactoring", "spelling", "design",
"invalid-name", "duplicate-code", "fixme",
"unused-wildcard-import", "cyclic-import", "wrong-import-order",
"wrong-import-position", "ungrouped-imports", "multiple-imports",
"logging-format-interpolation", "logging-fstring-interpolation",
"missing-function-docstring", "missing-module-docstring",
"missing-class-docstring", "raise-missing-from", "import-outside-toplevel",
[tool.ruff]
output-format = "full"
show-fixes = true

[tool.ruff.lint]
ignore = [
"N818", "S101", "ISC001", "PT004", "PT007", "RET502", "RET503", "SIM105", "SIM108", "SIM117",
"TRY003", "TRY300", "PLR2004", "PLW2901", "LOG007",
]
enable = ["c-extension-no-member", "no-else-return"]
select = [
"F", "E", "W", "C90", "I", "N", "UP", "YTT", "ASYNC", "S", "BLE", "B", "A", "C4", "T10",
"EXE", "ISC", "ICN", "G", "INP", "PIE", "T20", "PYI", "PT", "Q", "RSE", "RET",
"SLOT", "SIM", "TID", "TCH", "ARG", "PGH", "PLC", "PLE", "PLR", "PLW", "TRY",
"FLY", "PERF101", "LOG", "RUF", "RUF022", "RUF023", "RUF024", "RUF025", "RUF026",
]
preview = true
explicit-preview-rules = true

[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false
parametrize-names-type = "csv"
raises-extend-require-match-for = ["dvc.exceptions.DvcException"]

[tool.ruff.lint.flake8-tidy-imports]

[tool.ruff.lint.flake8-type-checking]
strict = true

[tool.ruff.lint.flake8-unused-arguments]
ignore-variadic-names = true

[tool.ruff.lint.isort]
known-first-party = ["dvc", "dvc_data", "dvc_objects"]

[tool.ruff.lint.pep8-naming]
extend-ignore-names = ["M", "SCM"]

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

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

0 comments on commit 676ba40

Please sign in to comment.