Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-commit fixes #763

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
7 changes: 1 addition & 6 deletions papermill/adl.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ def listdir(self, url):
"""Returns a list of the files under the specified path"""
(store_name, path) = self._split_url(url)
adapter = self._create_adapter(store_name)
return [
"adl://{store_name}.azuredatalakestore.net/{path_to_child}".format(
store_name=store_name, path_to_child=path_to_child
)
for path_to_child in adapter.ls(path)
]
return [f"adl://{store_name}.azuredatalakestore.net/{path_to_child}" for path_to_child in adapter.ls(path)]

def read(self, url):
"""Read storage at a given url"""
Expand Down
6 changes: 1 addition & 5 deletions papermill/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
def print_papermill_version(ctx, param, value):
if not value:
return
print(
"{version} from {path} ({pyver})".format(
version=papermill_version, path=__file__, pyver=platform.python_version()
)
)
print(f"{papermill_version} from {__file__} ({platform.python_version()})")
ctx.exit()


Expand Down
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 @@ -39,6 +39,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 @@ -47,6 +48,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