From 5447b1a5ced492831c04cdd86e36b26d22d6e9e4 Mon Sep 17 00:00:00 2001 From: Jirka Date: Fri, 23 Jun 2023 15:38:32 +0200 Subject: [PATCH 1/6] configure precommit --- .pre-commit-config.yaml | 26 ++++++++++++++++++++++++++ pyproject.toml | 15 +++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..310f79132 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,26 @@ +default_language_version: + python: python3 + +ci: + autofix_prs: true + autoupdate_commit_msg: '[pre-commit.ci] pre-commit suggestions' + autoupdate_schedule: quarterly + # submodules: true + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-yaml + - id: check-toml + - id: check-case-conflict + - id: check-added-large-files + - id: detect-private-key + + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: 'v0.0.272' + hooks: + - id: ruff + args: ["--fix"] diff --git a/pyproject.toml b/pyproject.toml index c6723bfd0..0def23df4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,3 +64,18 @@ include-package-data = false [tool.setuptools.dynamic] version = {attr = "joblib.__version__"} +[tool.ruff] +# line-length = 120 +# Enable Pyflakes `E` and `F` codes by default. +select = [ + "E", "W", # see: https://pypi.org/project/pycodestyle + "F", # see: https://pypi.org/project/pyflakes +] +# Exclude a variety of commonly ignored directories. +exclude = [ + "joblib/externals/*", +] +ignore-init-module-imports = true + +[tool.ruff.per-file-ignores] +"examples/*" = ["E402"] From ca477bba4edcf5722f818027b6a2d7701866135d Mon Sep 17 00:00:00 2001 From: Jirka Date: Fri, 23 Jun 2023 15:39:14 +0200 Subject: [PATCH 2/6] drop lint job --- azure-pipelines.yml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ba7810a97..f3ee9fb1b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,28 +14,6 @@ trigger: - master jobs: -- job: linting - displayName: Linting - pool: - vmImage: ubuntu-latest - steps: - - bash: echo "##vso[task.prependpath]$CONDA/bin" - displayName: Add conda to PATH - - bash: sudo chown -R $USER $CONDA - displayName: Take ownership of conda installation - - bash: conda create --name flake8_env --yes flake8 - displayName: Install flake8 - - bash: | - if [[ $BUILD_SOURCEVERSIONMESSAGE =~ \[lint\ skip\] ]]; then - # skip linting - echo "Skipping linting" - exit 0 - else - source activate flake8_env - flake8 - fi - displayName: Run linting - - job: testing displayName: Testing strategy: From 564a7d9f1a265aebcc99c2125489abc191874c88 Mon Sep 17 00:00:00 2001 From: Jirka Date: Fri, 23 Jun 2023 15:40:08 +0200 Subject: [PATCH 3/6] apply --- .mailmap | 1 - .pre-commit-config.yaml | 1 + .readthedocs.yaml | 1 - README.rst | 3 +-- TODO.rst | 12 +++++------- doc/_static/custom.css | 2 +- doc/_templates/layout.html | 1 - doc/conf.py | 2 +- doc/developing.rst | 1 - doc/why.rst | 3 --- joblib/func_inspect.py | 2 +- 11 files changed, 10 insertions(+), 19 deletions(-) diff --git a/.mailmap b/.mailmap index c234be035..499db29d0 100644 --- a/.mailmap +++ b/.mailmap @@ -3,4 +3,3 @@ Gael Varoquaux Gael varoquaux GaelVaroquaux Gael Varoquaux Gael VAROQUAUX Gael Varoquaux gvaroquaux - diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 310f79132..f75ed98d2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,3 +24,4 @@ repos: hooks: - id: ruff args: ["--fix"] + exclude: "joblib/test/test_func_inspect_special_encoding.py" diff --git a/.readthedocs.yaml b/.readthedocs.yaml index c451ca2e4..e8139c546 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -10,4 +10,3 @@ python: sphinx: fail_on_warning: true - diff --git a/README.rst b/README.rst index f9defa1db..e6d6b11c4 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,4 @@ -|PyPi| |Azure| |ReadTheDocs| |Codecov| +|PyPi| |Azure| |ReadTheDocs| |Codecov| .. |PyPi| image:: https://badge.fury.io/py/joblib.svg :target: https://badge.fury.io/py/joblib @@ -133,4 +133,3 @@ Changes are listed in the CHANGES.rst file. They must be manually updated but, the following git command may be used to generate the lines:: git log --abbrev-commit --date=short --no-merges --sparse - diff --git a/TODO.rst b/TODO.rst index 0028cc37b..96d6fd31e 100644 --- a/TODO.rst +++ b/TODO.rst @@ -4,14 +4,14 @@ Tasks at hand on joblib, in increasing order of difficulty. * In parallel: need to deal with return arguments that don't pickle. -* Improve test coverage and documentation +* Improve test coverage and documentation * Store a repr of the arguments for each call in the corresponding cachedir * Try to use Mike McKerns's Dill pickling module in Parallel: - Implementation idea: - * Create a new function that is wrapped and takes Dillo pickles as + Implementation idea: + * Create a new function that is wrapped and takes Dillo pickles as inputs as output, feed this one to multiprocessing * pickle everything using Dill in the Parallel object. http://dev.danse.us/trac/pathos/browser/dill @@ -26,7 +26,7 @@ Tasks at hand on joblib, in increasing order of difficulty. return a, b g = mem.cache(f) - g(c=2) + g(c=2) /home/varoquau/dev/joblib/joblib/func_inspect.pyc in filter_args(func, ignore_lst, *args, **kwargs), line 168 @@ -43,9 +43,7 @@ Tasks at hand on joblib, in increasing order of difficulty. accept as an input the dictionary of arguments, as returned in func_inspect, and return a string. -* add a sqlite db for provenance tracking. Store computation time and usage +* add a sqlite db for provenance tracking. Store computation time and usage timestamps, to be able to do 'garbage-collection-like' cleaning of unused results, based on a cost function balancing computation cost and frequency of use. - - diff --git a/doc/_static/custom.css b/doc/_static/custom.css index c931c7acb..4b66268bc 100644 --- a/doc/_static/custom.css +++ b/doc/_static/custom.css @@ -31,7 +31,7 @@ div.highlight pre { div.body table.docutils tr{ background: #ccc; /* fallback if nth-child is not supported */ } -div.body table.docutils tr:nth-child(odd){ +div.body table.docutils tr:nth-child(odd){ background: #f8f4ee; } div.body table.docutils tr:nth-child(even){ diff --git a/doc/_templates/layout.html b/doc/_templates/layout.html index 7a0bd17a1..23d83a1ac 100644 --- a/doc/_templates/layout.html +++ b/doc/_templates/layout.html @@ -19,4 +19,3 @@

Mailing list


{% endblock %} - diff --git a/doc/conf.py b/doc/conf.py index 429a996cb..27c2dfd7b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -247,7 +247,7 @@ ############################################################################## # Hack to copy the CHANGES.rst file -import shutil +import shutil # noqa: E402 try: shutil.copyfile('../CHANGES.rst', 'CHANGES.rst') shutil.copyfile('../README.rst', 'README.rst') diff --git a/doc/developing.rst b/doc/developing.rst index bab02e627..010bf2a17 100644 --- a/doc/developing.rst +++ b/doc/developing.rst @@ -6,4 +6,3 @@ Development .. include:: README.rst .. include:: CHANGES.rst - diff --git a/doc/why.rst b/doc/why.rst index 7d9fd098d..d1cd8e709 100644 --- a/doc/why.rst +++ b/doc/why.rst @@ -54,6 +54,3 @@ Design choices changing the original code * Only local imports: **embed joblib in your code by copying it** - - - diff --git a/joblib/func_inspect.py b/joblib/func_inspect.py index 3f8094614..aa647757f 100644 --- a/joblib/func_inspect.py +++ b/joblib/func_inspect.py @@ -164,7 +164,7 @@ def get_func_name(func, resolv_alias=True, win_characters=True): if resolv_alias: # TODO: Maybe add a warning here? if hasattr(func, 'func_globals') and name in func.func_globals: - if not func.func_globals[name] is func: + if func.func_globals[name] is not func: name = '%s-alias' % name if hasattr(func, '__qualname__') and func.__qualname__ != name: # Extend the module name in case of nested functions to avoid From b4255d09996c23e5c3616cd0ffdacecbb2eed5af Mon Sep 17 00:00:00 2001 From: Jirka Date: Fri, 23 Jun 2023 15:41:39 +0200 Subject: [PATCH 4/6] prune flake8 --- joblib/numpy_pickle.py | 4 +--- setup.cfg | 10 ---------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/joblib/numpy_pickle.py b/joblib/numpy_pickle.py index 3c6974a03..f3c6f844b 100644 --- a/joblib/numpy_pickle.py +++ b/joblib/numpy_pickle.py @@ -23,9 +23,7 @@ from .numpy_pickle_compat import NDArrayWrapper # For compatibility with old versions of joblib, we need ZNDArrayWrapper # to be visible in the current namespace. -# Explicitly skipping next line from flake8 as it triggers an F401 warning -# which we don't care. -from .numpy_pickle_compat import ZNDArrayWrapper # noqa +from .numpy_pickle_compat import ZNDArrayWrapper # noqa: F401 from .backports import make_memmap # Register supported compressors diff --git a/setup.cfg b/setup.cfg index f3bc114bb..7ec187a57 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,13 +13,3 @@ addopts = --doctest-modules --ignore joblib/externals testpaths = joblib - -[flake8] -exclude= - joblib/externals/*, - doc/auto_examples, - doc/_build, - -per-file-ignores = - examples/*: E402, - doc/conf.py: E402, From e5c084ea317d9a7d471afd7f59e380c80d8db635 Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:38:20 +0100 Subject: [PATCH 5/6] bump v0.3.0 --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f75ed98d2..6c3160417 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: - id: detect-private-key - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: 'v0.0.272' + rev: 'v0.3.0' hooks: - id: ruff args: ["--fix"] From 66c8911b67cff61c27053a62b54ec42abca0518f Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Thu, 7 Mar 2024 16:44:57 +0100 Subject: [PATCH 6/6] lint. --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 628e9cbd3..e36cce370 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,7 +100,7 @@ show_missing = true [tool.ruff] # line-length = 120 # Enable Pyflakes `E` and `F` codes by default. -select = [ +lint.select = [ "E", "W", # see: https://pypi.org/project/pycodestyle "F", # see: https://pypi.org/project/pyflakes ] @@ -108,7 +108,7 @@ select = [ exclude = [ "joblib/externals/*", ] -ignore-init-module-imports = true +lint.ignore-init-module-imports = true -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "examples/*" = ["E402"]