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 new file mode 100644 index 000000000..6c3160417 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +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.3.0' + hooks: + - id: ruff + args: ["--fix"] + exclude: "joblib/test/test_func_inspect_special_encoding.py" diff --git a/.readthedocs.yaml b/.readthedocs.yaml index d14bb8f9b..473ee29f3 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -16,4 +16,3 @@ python: sphinx: fail_on_warning: true - diff --git a/README.rst b/README.rst index 5880d6629..7150b25e4 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/azure-pipelines.yml b/azure-pipelines.yml index 8f985a011..dc52ae045 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,28 +15,6 @@ trigger: - main 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: diff --git a/doc/_templates/layout.html b/doc/_templates/layout.html index ad502bcac..03a18c987 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 4b99e8db9..976fdfd8a 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 diff --git a/joblib/numpy_pickle.py b/joblib/numpy_pickle.py index bf83bb091..b546f31bc 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/pyproject.toml b/pyproject.toml index 207f64f3d..aee1e120d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,3 +100,19 @@ relative_files = true [tool.coverage.report] show_missing = true + +[tool.ruff] +# line-length = 120 +# Enable Pyflakes `E` and `F` codes by default. +lint.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/*", +] +lint.ignore-init-module-imports = true + +[tool.ruff.lint.per-file-ignores] +"examples/*" = ["E402"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 56e8f46a6..000000000 --- a/setup.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# The prefered config file is pyproject.toml. The use of setup.cfg is -# mostly for compatibility with flake8 so it should not be used if possible. - -[flake8] -exclude= - joblib/externals/*, - doc/auto_examples, - doc/_build, - -per-file-ignores = - examples/*: E402, - doc/conf.py: E402,