From 46bd6ec6dcd548f990188174bdb973fb6719d8d9 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Thu, 19 Dec 2024 16:40:47 -0800 Subject: [PATCH 1/2] Configure ruff to check for style and format (#452) Remove `flake8`, `pylint` and `black` as requirements to check style and format the code in `env/requirements-style.txt` and `environment.yml`. Update targets in `Makefile` to use ruff to check for style and format the code. Add ruff configs to `pyproject.toml`. Remove the `.pylintrc` file. --- .github/workflows/style.yml | 2 +- .pylintrc | 392 ------------------------------------ Makefile | 11 +- env/requirements-style.txt | 5 +- environment.yml | 7 +- pyproject.toml | 50 ++++- 6 files changed, 56 insertions(+), 411 deletions(-) delete mode 100644 .pylintrc diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index 87e9d4db..75b83acb 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -58,4 +58,4 @@ jobs: run: python -m pip freeze - name: Check code style - run: make check-style lint + run: make check-style diff --git a/.pylintrc b/.pylintrc deleted file mode 100644 index 28db129c..00000000 --- a/.pylintrc +++ /dev/null @@ -1,392 +0,0 @@ -[MASTER] - -# A comma-separated list of package or module names from where C extensions may -# be loaded. Extensions are loading into the active Python interpreter and may -# run arbitrary code -extension-pkg-whitelist= - -# Add files or directories to the blacklist. They should be base names, not -# paths. -ignore=CVS,_version.py - -# Add files or directories matching the regex patterns to the blacklist. The -# regex matches against base names, not paths. -ignore-patterns= - -# Python code to execute, usually for sys.path manipulation such as -# pygtk.require(). -#init-hook= - -# Use multiple processes to speed up Pylint. -jobs=1 - -# List of plugins (as comma separated values of python modules names) to load, -# usually to register additional checkers. -load-plugins= - -# Pickle collected data for later comparisons. -persistent=yes - -# Specify a configuration file. -#rcfile= - -# Allow loading of arbitrary C extensions. Extensions are imported into the -# active Python interpreter and may run arbitrary code. -unsafe-load-any-extension=no - - -[MESSAGES CONTROL] - -# Only show warnings with the listed confidence levels. Leave empty to show -# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED -confidence= - -# Disable the message, report, category or checker with the given id(s). You -# can either give multiple identifiers separated by comma (,) or put this -# option multiple times (only on the command line, not in the configuration -# file where it should appear only once).You can also use "--disable=all" to -# disable everything first and then reenable specific checks. For example, if -# you want to run only the similarities checker, you can use "--disable=all -# --enable=similarities". If you want to run only the classes checker, but have -# no Warning level messages displayed, use"--disable=all --enable=classes -# --disable=W" -disable=raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,deprecated-pragma,attribute-defined-outside-init,similarities,,import-error - -# Enable the message, report, category or checker with the given id(s). You can -# either give multiple identifier separated by comma (,) or put this option -# multiple time (only on the command line, not in the configuration file where -# it should appear only once). See also the "--disable" option for examples. -enable= - - -[REPORTS] - -# Python expression which should return a note less than 10 (10 is the highest -# note). You have access to the variables errors warning, statement which -# respectively contain the number of errors / warnings messages and the total -# number of statements analyzed. This is used by the global evaluation report -# (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) - -# Template used to display messages. This is a python new-style format string -# used to format the message information. See doc for all details -#msg-template= - -# Set the output format. Available formats are text, parseable, colorized, json -# and msvs (visual studio).You can also give a reporter class, eg -# mypackage.mymodule.MyReporterClass. -output-format=text - -# Tells whether to display a full report or only the messages -reports=no - -# Activate the evaluation score. -score=yes - - -[REFACTORING] - -# Maximum number of nested blocks for function / method body -max-nested-blocks=5 - - -[FORMAT] - -# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. -expected-line-ending-format= - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 - -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' - -# Maximum number of characters on a single line. -max-line-length=100 - -# Maximum number of lines in a module -max-module-lines=2000 - -# Allow the body of a class to be on the same line as the declaration if body -# contains single statement. -single-line-class-stmt=no - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no - - -[VARIABLES] - -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= - -# Tells whether unused global variables should be treated as a violation. -allow-global-unused-variables=yes - -# List of strings which can identify a callback function by name. A callback -# name must start or end with one of those strings. -callbacks=cb_,_cb - -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=_+$|(_[a-zA-Z0-9_]*[a-zA-Z0-9]+?$)|dummy|^ignored_|^unused_ - -# Argument names that match this expression will be ignored. Default to name -# with leading underscore -ignored-argument-names=_.*|^ignored_|^unused_ - -# Tells whether we should check for unused import in __init__ files. -init-import=no - -# List of qualified module names which can have objects that can redefine -# builtins. -redefining-builtins-modules=six.moves,future.builtins - - -[SIMILARITIES] - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=yes - -# Minimum lines number of a similarity. -min-similarity-lines=3 - - -[LOGGING] - -# Logging modules to check that the string format arguments are in logging -# function parameter format -logging-modules=logging - - -[SPELLING] - -# Spelling dictionary name. Available dictionaries: none. To make it working -# install python-enchant package. -spelling-dict= - -# List of comma separated words that should not be checked. -spelling-ignore-words= - -# A path to a file that contains private dictionary; one word per line. -spelling-private-dict-file= - -# Tells whether to store unknown words to indicated private dictionary in -# --spelling-private-dict-file option instead of raising a message. -spelling-store-unknown-words=no - - -[BASIC] - -# Regular expression matching correct argument names -argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct attribute names -attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Bad variable names which should always be refused, separated by a comma -bad-names=foo,bar,baz,toto,tutu,tata - -# Regular expression matching correct class attribute names -class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - -# Regular expression matching correct class names -class-rgx=[A-Z_][a-zA-Z0-9]+$ - -# Regular expression matching correct constant names -const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - -# Minimum line length for functions/classes that require docstrings, shorter -# ones are exempt. -docstring-min-length=-1 - -# Regular expression matching correct function names -function-rgx=(([a-z][a-z0-9_]{2,50})|(_[a-z0-9_]*))$ - -# Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,w,e,s,n,x,y,z,cv,ax - -# Include a hint for the correct naming format with invalid-name -include-naming-hint=no - -# Regular expression matching correct inline iteration names -inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ - -# Regular expression matching correct method names -method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - -# Regular expression matching correct module names -module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - -# Colon-delimited sets of names that determine each other's naming style when -# the name regexes allow several styles. -name-group= - -# Regular expression which should only match function or class names that do -# not require a docstring. -no-docstring-rgx=^_ - -# List of decorators that produce properties, such as abc.abstractproperty. Add -# to this list to register other decorators that produce valid properties. -property-classes=abc.abstractproperty - -# Regular expression matching correct variable names -variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - - -[TYPECHECK] - -# List of decorators that produce context managers, such as -# contextlib.contextmanager. Add to this list to register other decorators that -# produce valid context managers. -contextmanager-decorators=contextlib.contextmanager - -# List of members which are set dynamically and missed by pylint inference -# system, and so shouldn't trigger E1101 when accessed. Python regular -# expressions are accepted. -generated-members= - -# Tells whether missing members accessed in mixin class should be ignored. A -# mixin class is detected if its name ends with "mixin" (case insensitive). -ignore-mixin-members=yes - -# This flag controls whether pylint should warn about no-member and similar -# checks whenever an opaque object is returned when inferring. The inference -# can return multiple potential results while evaluating a Python object, but -# some branches might not be evaluated, which results in partial inference. In -# that case, it might be useful to still emit no-member and other checks for -# the rest of the inferred objects. -ignore-on-opaque-inference=yes - -# List of class names for which member attributes should not be checked (useful -# for classes with dynamically set attributes). This supports the use of -# qualified names. -ignored-classes=optparse.Values,thread._local,_thread._local - -# List of module names for which member attributes should not be checked -# (useful for modules/projects where namespaces are manipulated during runtime -# and thus existing member attributes cannot be deduced by static analysis. It -# supports qualified module names, as well as Unix pattern matching. -ignored-modules= - -# Show a hint with possible names when a member name was not found. The aspect -# of finding the hint is based on edit distance. -missing-member-hint=yes - -# The minimum edit distance a name should have in order to be considered a -# similar match for a missing member name. -missing-member-hint-distance=1 - -# The total number of similar names that should be taken in consideration when -# showing a hint for a missing member. -missing-member-max-choices=1 - - -[MISCELLANEOUS] - -# List of note tags to take in consideration, separated by a comma. -notes=FIXME,XXX,TODO - - -[DESIGN] - -# Maximum number of arguments for function / method -max-args=10 - -# Maximum number of attributes for a class (see R0902). -max-attributes=10 - -# Maximum number of boolean expressions in a if statement -max-bool-expr=5 - -# Maximum number of branch for function / method body -max-branches=12 - -# Maximum number of locals for function / method body -max-locals=15 - -# Maximum number of parents for a class (see R0901). -max-parents=7 - -# Maximum number of public methods for a class (see R0904). -max-public-methods=20 - -# Maximum number of return / yield for function / method body -max-returns=6 - -# Maximum number of statements in function / method body -max-statements=50 - -# Minimum number of public methods for a class (see R0903). -min-public-methods=2 - -# Increase maximum positional arguemnts -max-positional-arguments=9 - - -[IMPORTS] - -# Allow wildcard imports from modules that define __all__. -allow-wildcard-with-all=no - -# Analyse import fallback blocks. This can be used to support both Python 2 and -# 3 compatible code, which means that the block might have code that exists -# only in one or another interpreter, leading to false positives when analysed. -analyse-fallback-blocks=no - -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=optparse,tkinter.tix - -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= - -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= - -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= - -# Force import order to recognize a module as part of the standard -# compatibility libraries. -known-standard-library= - -# Force import order to recognize a module as part of a third party library. -known-third-party=enchant - - -[CLASSES] - -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp - -# List of member names, which should be excluded from the protected access -# warning. -exclude-protected=_asdict,_fields,_replace,_source,_make - -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls - -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs - - -[EXCEPTIONS] - -# Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=Exception diff --git a/Makefile b/Makefile index 9d7ec156..5a3bd0c8 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,6 @@ help: @echo " test run the test suite (including doctests) and report coverage" @echo " format automatically format the code" @echo " check run code style and quality checks" - @echo " lint run pylint for a deeper (and slower) quality check" @echo " build build source and wheel distributions" @echo " clean clean up build and generated files" @echo "" @@ -31,20 +30,18 @@ test: rm -r $(TESTDIR) format: - black $(CHECK_STYLE) + ruff check --select I --fix $(CHECK_STYLE) # autoformat with isort + ruff format $(CHECK_STYLE) burocrata --extension=py $(CHECK_STYLE) check: check-format check-style check-format: - black --check $(CHECK_STYLE) + ruff format --check $(CHECK_STYLE) burocrata --check --extension=py $(CHECK_STYLE) check-style: - flake8 $(CHECK_STYLE) - -lint: - pylint --jobs=0 $(LINT_FILES) + ruff check $(CHECK_STYLE) clean: find . -name "*.pyc" -exec rm -v {} \; diff --git a/env/requirements-style.txt b/env/requirements-style.txt index 1a7e06ca..71f04564 100644 --- a/env/requirements-style.txt +++ b/env/requirements-style.txt @@ -1,6 +1,3 @@ # Style checks -black -flake8 -pylint>=2.4 -pathspec +ruff burocrata diff --git a/environment.yml b/environment.yml index b4d56569..77177d16 100644 --- a/environment.yml +++ b/environment.yml @@ -3,7 +3,7 @@ channels: - conda-forge - defaults dependencies: - - python==3.13 + - python==3.11 - pip # Run - requests @@ -27,9 +27,6 @@ dependencies: - sphinx-book-theme==1.1.* - sphinx-design==0.5.* # Style - - pathspec - - black>=20.8b1 - - flake8 - - pylint>=2.4 + - ruff - pip: - burocrata diff --git a/pyproject.toml b/pyproject.toml index b453da10..f3afbc9d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,8 +24,6 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", ] requires-python = ">=3.9" dependencies = [ @@ -75,3 +73,51 @@ notice = ''' # # This code is part of the Fatiando a Terra project (https://www.fatiando.org) #''' + +[tool.ruff] +line-length = 88 +exclude = [ + "doc/_build", + "pooch/_version.py", +] + +[tool.ruff.lint] +extend-select = [ + "ARG", # flake8-unused-arguments + "B", # flake8-bugbear + "C4", # flake8-comprehensions + "EM", # flake8-errmsg + "EXE", # flake8-executable + "FURB", # refurb + "G", # flake8-logging-format + "I", # isort + "ICN", # flake8-import-conventions + "NPY", # NumPy specific rules + "PD", # pandas-vet + "PGH", # pygrep-hooks + "PIE", # flake8-pie + "PL", # pylint + "PT", # flake8-pytest-style + "PTH", # flake8-use-pathlib + "PYI", # flake8-pyi + "RET", # flake8-return + "RUF", # Ruff-specific + "SIM", # flake8-simplify + "T20", # flake8-print + "UP", # pyupgrade + "YTT", # flake8-2020 +] +ignore = [ + "UP015", # ignore redundant modes in `open` (it's ok to be explicit) + "ISC001", # Conflicts with formatter + "PLR09", # Too many <...> + "PLR2004", # Magic value used in comparison + "PT001", # conventions for parenthesis on pytest.fixture + "RET504", # unnecessary assignment: allow to assign and return +] + +[tool.ruff.lint.per-file-ignores] +# disable unused-imports errors on __init__.py +"__init__.py" = ["F401"] +# allow print statements in tests +"pooch/tests/**" = ["T20"] From 1f34557eb229fc4c6251a0d4e2598801f4674a32 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Thu, 19 Dec 2024 16:50:14 -0800 Subject: [PATCH 2/2] Autoformat Pooch with ruff (#454) Run `make format` to autoformat Pooch codebase with Ruff. --- doc/conf.py | 3 +-- pooch/__init__.py | 16 +++++++--------- pooch/core.py | 16 ++++++++-------- pooch/downloaders.py | 8 +++----- pooch/hashes.py | 3 ++- pooch/processors.py | 5 +++-- pooch/tests/test_core.py | 25 ++++++++++++------------- pooch/tests/test_downloaders.py | 16 ++++++++-------- pooch/tests/test_hashes.py | 3 ++- pooch/tests/test_integration.py | 5 +++-- pooch/tests/test_processors.py | 9 ++++----- pooch/tests/test_utils.py | 7 ++++--- pooch/tests/test_version.py | 1 + pooch/tests/utils.py | 5 +++-- pooch/utils.py | 8 ++++---- 15 files changed, 65 insertions(+), 65 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index 6c7bb4de..d0583389 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -4,12 +4,11 @@ # # This code is part of the Fatiando a Terra project (https://www.fatiando.org) # -import os import datetime +import os import pooch - # Project information # ----------------------------------------------------------------------------- project = "Pooch" diff --git a/pooch/__init__.py b/pooch/__init__.py index 14d46b3f..068aae37 100644 --- a/pooch/__init__.py +++ b/pooch/__init__.py @@ -7,20 +7,18 @@ # pylint: disable=missing-docstring,import-outside-toplevel,import-self # # Import functions/classes to make the API +# This file is generated automatically by setuptools_scm +from . import _version from .core import Pooch, create, retrieve -from .utils import os_cache, check_version, get_logger -from .hashes import file_hash, make_registry from .downloaders import ( - HTTPDownloader, + DOIDownloader, FTPDownloader, + HTTPDownloader, SFTPDownloader, - DOIDownloader, ) -from .processors import Unzip, Untar, Decompress - -# This file is generated automatically by setuptools_scm -from . import _version - +from .hashes import file_hash, make_registry +from .processors import Decompress, Untar, Unzip +from .utils import check_version, get_logger, os_cache # Add a "v" to the version number __version__ = f"v{_version.version}" diff --git a/pooch/core.py b/pooch/core.py index db1014e9..c36ea7a7 100644 --- a/pooch/core.py +++ b/pooch/core.py @@ -7,25 +7,25 @@ """ The main Pooch class and a factory function for it. """ -import os -import time + import contextlib -from pathlib import Path +import os import shlex import shutil +import time +from pathlib import Path - -from .hashes import hash_matches, file_hash +from .downloaders import DOIDownloader, choose_downloader, doi_to_repository +from .hashes import file_hash, hash_matches from .utils import ( + cache_location, check_version, get_logger, make_local_storage, - cache_location, - temporary_file, os_cache, + temporary_file, unique_file_name, ) -from .downloaders import DOIDownloader, choose_downloader, doi_to_repository def retrieve( diff --git a/pooch/downloaders.py b/pooch/downloaders.py index 9500389b..890c8202 100644 --- a/pooch/downloaders.py +++ b/pooch/downloaders.py @@ -7,10 +7,10 @@ """ The classes that actually handle the downloads. """ + +import ftplib import os import sys -import ftplib - import warnings from .utils import parse_url @@ -171,9 +171,7 @@ def __init__(self, progressbar=False, chunk_size=1024, **kwargs): if self.progressbar is True and tqdm is None: raise ValueError("Missing package 'tqdm' required for progress bars.") - def __call__( - self, url, output_file, pooch, check_only=False - ): # pylint: disable=R0914 + def __call__(self, url, output_file, pooch, check_only=False): # pylint: disable=R0914 """ Download the given URL over HTTP to the given output file. diff --git a/pooch/hashes.py b/pooch/hashes.py index ebac68b9..b727f0b2 100644 --- a/pooch/hashes.py +++ b/pooch/hashes.py @@ -7,8 +7,9 @@ """ Calculating and checking file hashes. """ -import hashlib + import functools +import hashlib from pathlib import Path # From the docs: https://docs.python.org/3/library/hashlib.html#hashlib.new diff --git a/pooch/processors.py b/pooch/processors.py index 16670f9c..4cef3043 100644 --- a/pooch/processors.py +++ b/pooch/processors.py @@ -8,14 +8,15 @@ """ Post-processing hooks """ + import abc -import os import bz2 import gzip import lzma +import os import shutil -from zipfile import ZipFile from tarfile import TarFile +from zipfile import ZipFile from .utils import get_logger diff --git a/pooch/tests/test_core.py b/pooch/tests/test_core.py index fceda0a0..0521307c 100644 --- a/pooch/tests/test_core.py +++ b/pooch/tests/test_core.py @@ -8,6 +8,7 @@ """ Test the core class and factory function. """ + import hashlib import os from pathlib import Path @@ -15,26 +16,24 @@ import pytest -from ..core import create, Pooch, retrieve, download_action, stream_download -from ..utils import get_logger, temporary_file, os_cache -from ..hashes import file_hash, hash_matches - # Import the core module so that we can monkeypatch some functions from .. import core -from ..downloaders import HTTPDownloader, FTPDownloader - +from ..core import Pooch, create, download_action, retrieve, stream_download +from ..downloaders import FTPDownloader, HTTPDownloader +from ..hashes import file_hash, hash_matches +from ..utils import get_logger, os_cache, temporary_file from .utils import ( - pooch_test_url, + capture_log, + check_large_data, + check_tiny_data, data_over_ftp, + mirror_directory, + pooch_test_dataverse_url, pooch_test_figshare_url, + pooch_test_registry, + pooch_test_url, pooch_test_zenodo_url, pooch_test_zenodo_with_slash_url, - pooch_test_dataverse_url, - pooch_test_registry, - check_tiny_data, - check_large_data, - capture_log, - mirror_directory, ) DATA_DIR = str(Path(__file__).parent / "data") diff --git a/pooch/tests/test_downloaders.py b/pooch/tests/test_downloaders.py index 14e32f92..b567ed29 100644 --- a/pooch/tests/test_downloaders.py +++ b/pooch/tests/test_downloaders.py @@ -7,6 +7,7 @@ """ Test the downloader classes and functions separately from the Pooch core. """ + import os import sys from tempfile import TemporaryDirectory @@ -25,29 +26,28 @@ from .. import Pooch from ..downloaders import ( - HTTPDownloader, - FTPDownloader, - SFTPDownloader, + DataverseRepository, DOIDownloader, - choose_downloader, FigshareRepository, + FTPDownloader, + HTTPDownloader, + SFTPDownloader, ZenodoRepository, - DataverseRepository, + choose_downloader, doi_to_url, ) from ..processors import Unzip from .utils import ( - pooch_test_url, check_large_data, check_tiny_data, data_over_ftp, + pooch_test_dataverse_url, pooch_test_figshare_url, + pooch_test_url, pooch_test_zenodo_url, pooch_test_zenodo_with_slash_url, - pooch_test_dataverse_url, ) - BASEURL = pooch_test_url() FIGSHAREURL = pooch_test_figshare_url() ZENODOURL = pooch_test_zenodo_url() diff --git a/pooch/tests/test_hashes.py b/pooch/tests/test_hashes.py index cf6897e2..8fa4888c 100644 --- a/pooch/tests/test_hashes.py +++ b/pooch/tests/test_hashes.py @@ -8,6 +8,7 @@ """ Test the hash calculation and checking functions. """ + import os from pathlib import Path from tempfile import NamedTemporaryFile @@ -24,9 +25,9 @@ from ..core import Pooch from ..hashes import ( - make_registry, file_hash, hash_matches, + make_registry, ) from .utils import check_tiny_data, mirror_directory diff --git a/pooch/tests/test_integration.py b/pooch/tests/test_integration.py index 831a41f9..741450d4 100644 --- a/pooch/tests/test_integration.py +++ b/pooch/tests/test_integration.py @@ -8,15 +8,16 @@ """ Test the entire process of creating a Pooch and using it. """ + import os import shutil from pathlib import Path import pytest -from .. import create, os_cache from .. import __version__ as full_version -from .utils import check_tiny_data, capture_log +from .. import create, os_cache +from .utils import capture_log, check_tiny_data @pytest.mark.network diff --git a/pooch/tests/test_processors.py b/pooch/tests/test_processors.py index 1a2a1e2a..9ee1f60a 100644 --- a/pooch/tests/test_processors.py +++ b/pooch/tests/test_processors.py @@ -7,17 +7,16 @@ """ Test the processor hooks """ + +import warnings from pathlib import Path from tempfile import TemporaryDirectory -import warnings import pytest from .. import Pooch -from ..processors import Unzip, Untar, Decompress - -from .utils import pooch_test_url, pooch_test_registry, check_tiny_data, capture_log - +from ..processors import Decompress, Untar, Unzip +from .utils import capture_log, check_tiny_data, pooch_test_registry, pooch_test_url REGISTRY = pooch_test_registry() BASEURL = pooch_test_url() diff --git a/pooch/tests/test_utils.py b/pooch/tests/test_utils.py index 71401297..77ea647d 100644 --- a/pooch/tests/test_utils.py +++ b/pooch/tests/test_utils.py @@ -7,19 +7,20 @@ """ Test the utility functions. """ + import os import shutil +import tempfile import time +from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor from pathlib import Path -import tempfile from tempfile import TemporaryDirectory -from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor import pytest from ..utils import ( - parse_url, make_local_storage, + parse_url, temporary_file, unique_file_name, ) diff --git a/pooch/tests/test_version.py b/pooch/tests/test_version.py index 17e392ca..dcabad83 100644 --- a/pooch/tests/test_version.py +++ b/pooch/tests/test_version.py @@ -7,6 +7,7 @@ """ Test the version. """ + from packaging.version import Version import pooch diff --git a/pooch/tests/utils.py b/pooch/tests/utils.py index a248ead7..ea0fcff5 100644 --- a/pooch/tests/utils.py +++ b/pooch/tests/utils.py @@ -7,13 +7,14 @@ """ Utilities for testing code. """ -import os + import io import logging +import os import shutil import stat -from pathlib import Path from contextlib import contextmanager +from pathlib import Path from .. import __version__ as full_version from ..utils import check_version, get_logger diff --git a/pooch/utils.py b/pooch/utils.py index fb88dab7..f48285dc 100644 --- a/pooch/utils.py +++ b/pooch/utils.py @@ -7,19 +7,19 @@ """ Misc utilities """ + +import hashlib import logging import os import tempfile -import hashlib +import warnings +from contextlib import contextmanager from pathlib import Path from urllib.parse import urlsplit -from contextlib import contextmanager -import warnings import platformdirs from packaging.version import Version - LOGGER = logging.Logger("pooch") LOGGER.addHandler(logging.StreamHandler())