Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.2.2"
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
rev: v2.3.0
hooks:
- id: autoflake
name: autoflake
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 @@ -24,20 +25,15 @@ repos:
hooks:
- id: rst-backticks
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.1
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:
- id: blacken-docs
additional_dependencies: [black==22.10.0]
additional_dependencies: [black==24.2.0]
- repo: local
hooks:
- id: rst
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
3 changes: 2 additions & 1 deletion scripts/release.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""
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
3 changes: 2 additions & 1 deletion src/pluggy/_callers.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
"""
Call loop machinery
"""

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
3 changes: 2 additions & 1 deletion src/pluggy/_hooks.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""
Internal hook annotation, representation and calling machinery.
"""

from __future__ import annotations

import inspect
import sys
import warnings
from types import ModuleType
from typing import AbstractSet
from typing import Any
Expand All @@ -23,6 +23,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 src/pluggy/_result.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Hook wrapper "result" utilities.
"""

from __future__ import annotations

from types import TracebackType
Expand Down
1 change: 1 addition & 0 deletions src/pluggy/_tracing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tracing utils
"""

from __future__ import annotations

from typing import Any
Expand Down
1 change: 1 addition & 0 deletions testing/benchmark.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Benchmarking and performance tests.
"""

import pytest

from pluggy import HookimplMarker
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
1 change: 1 addition & 0 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
``PluginManager`` unit and public API testing.
"""

import importlib.metadata
from typing import Any
from typing import List
Expand Down