update pre-commit; add some more hooks (#8492)

* update pre-commit; add some more hooks

* Apply suggestions from code review
This commit is contained in:
skshetry
2022-10-31 21:04:11 +05:45
committed by GitHub
parent 4ca2158b9d
commit 6df70d388e
15 changed files with 69 additions and 46 deletions
@@ -2,4 +2,3 @@
name: "\U0001F680 Feature Request" name: "\U0001F680 Feature Request"
about: Suggest an idea for this project about: Suggest an idea for this project
--- ---
+42 -27
View File
@@ -1,39 +1,62 @@
default_language_version:
python: python3
ci: ci:
skip: [mypy, pylint, dvc-pre-commit] skip: [mypy, pylint, dvc-pre-commit]
repos: repos:
- hooks:
- id: black
language_version: python3
repo: https://github.com/ambv/black
rev: 22.10.0
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0 rev: v4.3.0
hooks: hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
exclude: "tests/func/utils/test_strict_yaml.py"
args: ['--assume-in-merge']
- id: check-toml - id: check-toml
- id: check-yaml - id: check-yaml
- hooks: - id: debug-statements
- id: codespell exclude: "dvc/_debug.py"
- id: end-of-file-fixer
- id: mixed-line-ending
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: https://github.com/lovesegfault/beautysh
rev: v6.2.1
hooks:
- id: beautysh
args: ["-i", "2"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.0
hooks:
- id: pyupgrade
args: args:
- --ignore-words-list - --py38-plus
- ba,datas,fo,uptodate,cachable,falsy - repo: https://github.com/psf/black
repo: https://github.com/codespell-project/codespell rev: 22.10.0
rev: v2.2.2 hooks:
- hooks: - id: black
- id: isort - repo: https://github.com/PyCQA/isort
language_version: python3
repo: https://github.com/timothycrosley/isort
rev: 5.10.1 rev: 5.10.1
- hooks: hooks:
- id: isort
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
additional_dependencies: ["tomli"]
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8 - id: flake8
language_version: python3
additional_dependencies: additional_dependencies:
- flake8-broken-line
- flake8-bugbear - flake8-bugbear
- flake8-comprehensions - flake8-comprehensions
- flake8-debugger - flake8-debugger
- flake8-string-format - flake8-string-format
repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: local - repo: local
hooks: hooks:
- id: mypy - id: mypy
@@ -47,14 +70,6 @@ repos:
entry: pylint entry: pylint
language: system language: system
types: [python] types: [python]
- hooks:
- args:
- -i
- "2"
id: beautysh
language_version: python3
repo: https://github.com/lovesegfault/beautysh
rev: v6.2.1
- hooks: - hooks:
- args: - args:
- git-hook - git-hook
-1
View File
@@ -74,4 +74,3 @@ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.ht
For answers to common questions about this code of conduct, see For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq https://www.contributor-covenant.org/faq
+1 -1
View File
@@ -26,7 +26,7 @@ class BaseMachineBackend(ABC):
) -> Iterator[dict]: ) -> Iterator[dict]:
"""Iterate over status of all instances of the specified machine.""" """Iterate over status of all instances of the specified machine."""
def close(self): def close(self): # noqa: B027
pass pass
@abstractmethod @abstractmethod
+1 -1
View File
@@ -36,7 +36,7 @@ from .interpolate import (
) )
if TYPE_CHECKING: if TYPE_CHECKING:
from typing_extensions import NoReturn from typing import NoReturn
from dvc.repo import Repo from dvc.repo import Repo
+1 -2
View File
@@ -9,10 +9,9 @@ from dvc.exceptions import DvcException
from dvc.utils.flatten import flatten from dvc.utils.flatten import flatten
if typing.TYPE_CHECKING: if typing.TYPE_CHECKING:
from typing import List, Match from typing import List, Match, NoReturn
from pyparsing import ParseException from pyparsing import ParseException
from typing_extensions import NoReturn
from .context import Context from .context import Context
+1
View File
@@ -269,6 +269,7 @@ class BaseStashQueue(ABC):
finish any active experiments before shutting down. finish any active experiments before shutting down.
""" """
@abstractmethod
def logs( def logs(
self, self,
rev: str, rev: str,
+1 -1
View File
@@ -65,7 +65,7 @@ class Cloud(ABC):
self._gen(struct) self._gen(struct)
return struct.keys() return struct.keys()
def close(self): def close(self): # noqa: B027
pass pass
@staticmethod @staticmethod
+9 -2
View File
@@ -1,10 +1,17 @@
"""Common utilities for serialize.""" """Common utilities for serialize."""
import os import os
from contextlib import contextmanager from contextlib import contextmanager
from typing import TYPE_CHECKING, Any, Callable, ContextManager, Dict, Union from typing import (
TYPE_CHECKING,
Any,
Callable,
ContextManager,
Dict,
Protocol,
Union,
)
from funcy import reraise from funcy import reraise
from typing_extensions import Protocol
from dvc.exceptions import DvcException from dvc.exceptions import DvcException
+3
View File
@@ -81,3 +81,6 @@ signature-mutators = ["funcy.decorators.decorator"]
[tool.pylint.variables] [tool.pylint.variables]
dummy-variables-rgx = "_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_" dummy-variables-rgx = "_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_"
ignored-argument-names = "_.*|^ignored_|^unused_|args|kwargs" ignored-argument-names = "_.*|^ignored_|^unused_|args|kwargs"
[tool.codespell]
ignore-words-list = "ba,datas,fo,uptodate,cachable,falsy"
+1 -1
View File
@@ -17,7 +17,7 @@ from ..utils.test_hydra import hydra_setup
def test_modify_params(params_repo, dvc, changes, expected): def test_modify_params(params_repo, dvc, changes, expected):
dvc.experiments.run(params=changes) dvc.experiments.run(params=changes)
# pylint: disable=unspecified-encoding # pylint: disable=unspecified-encoding
with open("params.yaml", mode="r") as fobj: with open("params.yaml") as fobj:
assert fobj.read().strip() == expected assert fobj.read().strip() == expected
+1 -1
View File
@@ -44,7 +44,7 @@ def extract_vega_specs(html_path, plots_ids):
result = {} result = {}
with open(html_path, "r", encoding="utf-8") as fd: with open(html_path, encoding="utf-8") as fd:
content = fd.read() content = fd.read()
reader = BeautifulSoup(content, features="html.parser") reader = BeautifulSoup(content, features="html.parser")