Skip to content

Commit

Permalink
Merge pull request #482 from Pierre-Sassoulas/main
Browse files Browse the repository at this point in the history
Migrate from ``reorder-python-imports`` / ``black`` to ``ruff`` / ``isort``
  • Loading branch information
bluetech authored Feb 20, 2024
2 parents 4326ced + 33ca1a9 commit 8c2435d
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 31 deletions.
16 changes: 6 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.2.0"
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
hooks:
Expand All @@ -7,11 +13,6 @@ repos:
args: ["--in-place", "--remove-unused-variables", "--remove-all-unused-imports"]
language: python
files: \.py$
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.12.0
hooks:
- id: reorder-python-imports
args: ['--application-directories=.:src', --py38-plus]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.1.0
hooks:
Expand All @@ -28,11 +29,6 @@ repos:
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
Expand Down
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from importlib import metadata
from typing import TYPE_CHECKING


if TYPE_CHECKING:
import sphinx.application

Expand Down Expand Up @@ -104,9 +105,10 @@

def configure_logging(app: "sphinx.application.Sphinx") -> None:
"""Configure Sphinx's WarningHandler to handle (expected) missing include."""
import sphinx.util.logging
import logging

import sphinx.util.logging

class WarnLogFilter(logging.Filter):
def filter(self, record: logging.LogRecord) -> bool:
"""Ignore warnings about missing include with "only" directive.
Expand Down
1 change: 1 addition & 0 deletions docs/examples/eggsample-spam/setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from setuptools import setup


setup(
name="eggsample-spam",
install_requires="eggsample",
Expand Down
1 change: 1 addition & 0 deletions docs/examples/eggsample/eggsample/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pluggy


hookimpl = pluggy.HookimplMarker("eggsample")
"""Marker to be imported and used in plugins (and for own implementations)"""
1 change: 1 addition & 0 deletions docs/examples/eggsample/eggsample/hookspecs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pluggy


hookspec = pluggy.HookspecMarker("eggsample")


Expand Down
1 change: 1 addition & 0 deletions docs/examples/eggsample/eggsample/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pluggy


condiments_tray = {"pickled walnuts": 13, "steak sauce": 4, "mushy peas": 2}


Expand Down
1 change: 1 addition & 0 deletions docs/examples/eggsample/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from setuptools import find_packages
from setuptools import setup


setup(
name="eggsample",
install_requires="pluggy>=0.3,<1.0",
Expand Down
1 change: 1 addition & 0 deletions docs/examples/toy-example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pluggy


hookspec = pluggy.HookspecMarker("myproject")
hookimpl = pluggy.HookimplMarker("myproject")

Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ requires = [
]
build-backend = "setuptools.build_meta"


[tool.ruff.lint]
select = [
"I", # isort
]

[tool.ruff.lint.isort]
force-single-line = true
combine-as-imports = true
force-sort-within-sections = true
order-by-type = false
known-local-folder = ["pluggy"]
lines-after-imports = 2

[tool.setuptools_scm]
write_to = "src/pluggy/_version.py"

Expand Down
2 changes: 1 addition & 1 deletion scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Release script.
"""
import argparse
import sys
from subprocess import check_call
import sys

from colorama import Fore
from colorama import init
Expand Down
2 changes: 1 addition & 1 deletion scripts/towncrier-draft-to-file.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
from subprocess import call
import sys


def main():
Expand Down
28 changes: 13 additions & 15 deletions src/pluggy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@
"PluggyTeardownRaisedWarning",
]

from ._manager import PluginManager, PluginValidationError
from ._result import HookCallError, Result
from ._hooks import (
HookspecMarker,
HookimplMarker,
HookCaller,
HookRelay,
HookspecOpts,
HookimplOpts,
HookImpl,
)
from ._warnings import (
PluggyWarning,
PluggyTeardownRaisedWarning,
)
from ._hooks import HookCaller
from ._hooks import HookImpl
from ._hooks import HookimplMarker
from ._hooks import HookimplOpts
from ._hooks import HookRelay
from ._hooks import HookspecMarker
from ._hooks import HookspecOpts
from ._manager import PluginManager
from ._manager import PluginValidationError
from ._result import HookCallError
from ._result import Result
from ._warnings import PluggyTeardownRaisedWarning
from ._warnings import PluggyWarning
2 changes: 1 addition & 1 deletion src/pluggy/_callers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"""
from __future__ import annotations

import warnings
from typing import cast
from typing import Generator
from typing import Mapping
from typing import NoReturn
from typing import Sequence
from typing import Tuple
from typing import Union
import warnings

from ._hooks import HookImpl
from ._result import HookCallError
Expand Down
2 changes: 1 addition & 1 deletion src/pluggy/_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import inspect
import sys
import warnings
from types import ModuleType
from typing import AbstractSet
from typing import Any
Expand All @@ -23,6 +22,7 @@
from typing import TypedDict
from typing import TypeVar
from typing import Union
import warnings

from ._result import Result

Expand Down
3 changes: 2 additions & 1 deletion src/pluggy/_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import inspect
import types
import warnings
from typing import Any
from typing import Callable
from typing import cast
Expand All @@ -11,6 +10,7 @@
from typing import Mapping
from typing import Sequence
from typing import TYPE_CHECKING
import warnings

from . import _tracing
from ._callers import _multicall
Expand All @@ -26,6 +26,7 @@
from ._hooks import normalize_hookimpl_opts
from ._result import Result


if TYPE_CHECKING:
# importtlib.metadata import is slow, defer it.
import importlib.metadata
Expand Down
1 change: 1 addition & 0 deletions testing/test_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pluggy import HookspecMarker
from pluggy import PluginManager


hookspec = HookspecMarker("example")
hookimpl = HookimplMarker("example")

Expand Down
1 change: 1 addition & 0 deletions testing/test_hookcaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pluggy._hooks import HookCaller
from pluggy._hooks import HookImpl


hookspec = HookspecMarker("example")
hookimpl = HookimplMarker("example")

Expand Down

0 comments on commit 8c2435d

Please sign in to comment.