diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7530b7e..8a9a07d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,21 +9,20 @@ repos: - id: check-docstring-first - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/PyCQA/isort - rev: 6.0.1 + - repo: https://github.com/PyCQA/docformatter + rev: v1.7.7 hooks: - - id: isort - additional_dependencies: [toml] - - repo: https://github.com/asottile/pyupgrade - rev: v3.20.0 + - id: docformatter + args: [--in-place, --black] + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.12.4 hooks: - - id: pyupgrade - args: [--py38-plus] - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 25.1.0 + - id: ruff-format + - id: ruff-check + args: [ --fix ] + - repo: https://github.com/codespell-project/codespell + rev: v2.4.1 hooks: - - id: black - - repo: https://github.com/PyCQA/flake8 - rev: 7.3.0 - hooks: - - id: flake8 + - id: codespell + # remove toml extra once Python 3.10 is no longer supported + additional_dependencies: ['.[toml]'] diff --git a/pth-tester/pth_tester.py b/pth-tester/pth_tester.py index a052e9a..3795ec0 100644 --- a/pth-tester/pth_tester.py +++ b/pth-tester/pth_tester.py @@ -2,7 +2,7 @@ has_socket = False -# The pth_tester module should be initalized by processing the `.pth` file +# The pth_tester module should be initialized by processing the `.pth` file # created on installation. def init(): global initialized diff --git a/pth-tester/setup.py b/pth-tester/setup.py index b1ace4a..5ed74c5 100644 --- a/pth-tester/setup.py +++ b/pth-tester/setup.py @@ -7,8 +7,7 @@ # Copied from setuptools: # (https://github.com/pypa/setuptools/blob/7c859e017368360ba66c8cc591279d8964c031bc/setup.py#L40C6-L82) class install_with_pth(install): - """ - Custom install command to install a .pth file. + """Custom install command to install a .pth file. This hack is necessary because there's no standard way to install behavior on startup (and it's debatable if there should be one). This hack (ab)uses @@ -30,9 +29,7 @@ def finalize_options(self): self._restore_install_lib() def _restore_install_lib(self): - """ - Undo secondary effect of `extra_path` adding to `install_lib` - """ + """Undo secondary effect of `extra_path` adding to `install_lib`""" suffix = os.path.relpath(self.install_lib, self.install_libbase) if suffix.strip() == self._pth_contents.strip(): diff --git a/pyproject.toml b/pyproject.toml index 3d1081b..00309ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,8 +31,8 @@ requires = [ (platform_system != 'iOS' and platform_system != 'Android' and python_version < '3.14') \ or (platform_system == 'iOS' and python_version < '3.14') \ or (platform_system == 'Android' and python_version < '3.14')""", - # pillow not available anywhere on 3.14 - """pillow; \ + # pillow not available anywhere on 3.14. 11.3.0 wheel is known bad on iOS. + """pillow != 11.3.0; \ (platform_system != 'iOS' and platform_system != 'Android' and python_version < '3.14') \ or (platform_system == 'iOS' and python_version < '3.14') \ or (platform_system == 'Android' and python_version < '3.14')""", @@ -108,7 +108,7 @@ flatpak_sdk = "org.gnome.Sdk" [tool.briefcase.app.testbed.windows] requires = [ - # Python.net isn't avaialble for 3.14 yet. + # Python.net isn't available for 3.14 yet. "pythonnet>=3.0.0; python_version < '3.14'", # Windows doesn't provide the zoneinfo TZ database; use the Python provided one "tzdata", @@ -143,7 +143,20 @@ build_gradle_dependencies = [ # template = "../../templates/briefcase-android-gradle-template" -[tool.isort] -profile = "black" -split_on_trailing_comma = true -combine_as_imports = true +[tool.ruff.lint] +# In addition to the default rules, these additional rules will be used: +extend-select = [ + "E", # pycodestyle + "W", # pycodestyle + "F", # pyflakes + "UP", # pyupgrade + "B", # flake8-bugbear + "YTT", # flake8-2020 + "ASYNC", # flake8-async + "C4", # flake8-comprehensions + "I", # isort + # The SIM rules are *very* opinionated, and don't necessarily make for better code. + # They may be worth occasionally turning on just to see if something could actually + # use improvement. + # "SIM", # flake8-simplify +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index aad4b0b..0000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ - -[flake8] -max-complexity = 25 -max-line-length = 119 -ignore = E203,E266,E501,W503 diff --git a/tests/test_common.py b/tests/test_common.py index ad8b2fc..bb628f7 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -51,9 +51,9 @@ def test_bootstrap_modules(): except ModuleNotFoundError: missing.append(module) - assert ( - len(missing) == 0 - ), f"Missing bootstrap modules: {', '.join(str(m) for m in missing)}" + assert len(missing) == 0, ( + f"Missing bootstrap modules: {', '.join(str(m) for m in missing)}" + ) def test_stdlib_modules(): @@ -139,9 +139,9 @@ def test_stdlib_modules(): except ModuleNotFoundError: missing.append(module) - assert ( - len(missing) == 0 - ), f"Missing stdlib modules: {', '.join(str(m) for m in missing)}" + assert len(missing) == 0, ( + f"Missing stdlib modules: {', '.join(str(m) for m in missing)}" + ) def test_sysconfig_data(): @@ -284,9 +284,9 @@ def test_hashlib(): digest_args = [] msg = getattr(hashlib, algorithm)() msg.update(b"Hello world") - assert ( - msg.hexdigest(*digest_args) == expected - ), f"{algorithm} digest was {msg.hexdigest(*digest_args)}" + assert msg.hexdigest(*digest_args) == expected, ( + f"{algorithm} digest was {msg.hexdigest(*digest_args)}" + ) def test_sqlite3(): diff --git a/tests/test_macOS.py b/tests/test_macOS.py index a71bfa1..f5a6e12 100644 --- a/tests/test_macOS.py +++ b/tests/test_macOS.py @@ -81,6 +81,6 @@ def test_stdlib_modules(): except ModuleNotFoundError: missing.append(module) - assert ( - len(missing) == 0 - ), f"Missing stdlib modules: {', '.join(str(m) for m in missing)}" + assert len(missing) == 0, ( + f"Missing stdlib modules: {', '.join(str(m) for m in missing)}" + ) diff --git a/tests/test_thirdparty.py b/tests/test_thirdparty.py index 31f1846..aab7b08 100644 --- a/tests/test_thirdparty.py +++ b/tests/test_thirdparty.py @@ -11,7 +11,8 @@ def xfail_if_not_installed(package_name): """A test decorator that xfails a test if the named package isn't installed. - The third-party tests are dependant on packages being built. During pre-release some + + The third-party tests are dependent on packages being built. During pre-release some packages won't be compilable. So - the pyproject.toml installs third party packages with some conditional gating. @@ -191,10 +192,10 @@ def test_pandas(): # Pandas 1.5 changed the API for to_csv() if tuple(int(v) for v in __version__.split(".")[:2]) < (1, 5): - kwargs = dict(line_terminator="\n") + kwargs = {"line_terminator": "\n"} else: - kwargs = dict(lineterminator="\n") + kwargs = {"lineterminator": "\n"} - assert ( - ",Letter,Number\n" "0,alpha,1\n" "1,bravo,2\n" "2,charlie,3\n" - ) == df.to_csv(**kwargs) + assert (",Letter,Number\n0,alpha,1\n1,bravo,2\n2,charlie,3\n") == df.to_csv( + **kwargs + ) diff --git a/tests/testbed.py b/tests/testbed.py index f381dc5..339e5cb 100644 --- a/tests/testbed.py +++ b/tests/testbed.py @@ -32,7 +32,7 @@ def run_tests(): # macOS, output the log sentinel multiple times to decrease the chance of # this happening. if sys.platform in {"darwin", "ios"}: - for i in range(0, 6): + for _ in range(0, 6): time.sleep(0.5) print(f">>>>>>>>>> EXIT {returncode} <<<<<<<<<<") else: