Skip to content

Commit

Permalink
Pre-commit fixes (#763)
Browse files Browse the repository at this point in the history
* pre-commit: don't prescribe python 3.8

* pre-commit: get rid of yesqa, it's for flake8 only

flake8 was dropped in #752

* pre-commit: use ruff's UP rules instead of pyupgrade
  • Loading branch information
akx authored Dec 18, 2023
1 parent bc9c607 commit 6864fdc
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 24 deletions.
17 changes: 1 addition & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
default_language_version:
python: python3.8

ci:
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions'
Expand All @@ -21,13 +18,6 @@ repos:
- id: check-docstring-first
- id: detect-private-key

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py38-plus"]
name: Upgrade code

#- repo: https://github.com/myint/docformatter
# rev: v1.5.0
# hooks:
Expand Down Expand Up @@ -55,13 +45,8 @@ repos:
- mdformat-gfm
- mdformat_frontmatter

- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
rev: v0.1.8
hooks:
- id: ruff
args: ["--fix"]
10 changes: 5 additions & 5 deletions papermill/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class PapermillParameterOverwriteWarning(PapermillWarning):
def missing_dependency_generator(package, dep):
def missing_dep():
raise PapermillOptionalDependencyException(
"The {package} optional dependency is missing. "
"Please run pip install papermill[{dep}] to install this dependency".format(package=package, dep=dep)
f"The {package} optional dependency is missing. "
f"Please run pip install papermill[{dep}] to install this dependency"
)

return missing_dep
Expand All @@ -69,9 +69,9 @@ def missing_dep():
def missing_environment_variable_generator(package, env_key):
def missing_dep():
raise PapermillOptionalDependencyException(
"The {package} optional dependency is present, but the environment "
"variable {env_key} is not set. Please set this variable as "
"required by {package} on your platform.".format(package=package, env_key=env_key)
f"The {package} optional dependency is present, but the environment "
f"variable {env_key} is not set. Please set this variable as "
f"required by {package} on your platform."
)

return missing_dep
2 changes: 1 addition & 1 deletion papermill/tests/test_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_str_path():
[
"Dummy usage",
"\nParameters inferred for notebook '{name}':",
"\n Can't infer anything about this notebook's parameters. It may not have any parameter defined.", # noqa
"\n Can't infer anything about this notebook's parameters. It may not have any parameter defined.",
],
),
],
Expand Down
2 changes: 1 addition & 1 deletion papermill/tests/test_translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_translate_comment_python(test_input, expected):
[Parameter("a", "List[str]", "['this','is','a','string','list']", "Nice variable a")],
),
(
"a: List[str] = [\n 'this',\n 'is',\n 'a',\n 'string',\n 'list'\n] # Nice variable a", # noqa
"a: List[str] = [\n 'this',\n 'is',\n 'a',\n 'string',\n 'list'\n] # Nice variable a",
[Parameter("a", "List[str]", "['this','is','a','string','list']", "Nice variable a")],
),
(
Expand Down
2 changes: 1 addition & 1 deletion papermill/translators.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def inspect(cls, parameters_cell):
class PythonTranslator(Translator):
# Pattern to capture parameters within cell input
PARAMETER_PATTERN = re.compile(
r"^(?P<target>\w[\w_]*)\s*(:\s*[\"']?(?P<annotation>\w[\w_\[\],\s]*)[\"']?\s*)?=\s*(?P<value>.*?)(\s*#\s*(type:\s*(?P<type_comment>[^\s]*)\s*)?(?P<help>.*))?$" # noqa
r"^(?P<target>\w[\w_]*)\s*(:\s*[\"']?(?P<annotation>\w[\w_\[\],\s]*)[\"']?\s*)?=\s*(?P<value>.*?)(\s*#\s*(type:\s*(?P<type_comment>[^\s]*)\s*)?(?P<help>.*))?$"
)

@classmethod
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ignore-words-list = "dne, compiletime"


[tool.ruff]
target-version = "py38"
line-length = 120
# Enable Pyflakes `E` and `F` codes by default.
select = [
Expand All @@ -42,6 +43,8 @@ select = [
"I", # isort
# "D", # see: https://pypi.org/project/pydocstyle
# "N", # see: https://pypi.org/project/pep8-naming
"RUF100", # unnecessary noqa comment
"UP", # pyupgrade
]
#extend-select = [
# "C4", # see: https://pypi.org/project/flake8-comprehensions
Expand Down

0 comments on commit 6864fdc

Please sign in to comment.