Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #83

Merged
merged 5 commits into from
Mar 24, 2024
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
13 changes: 4 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,17 @@ repos:
- id: python-no-log-warn
- id: python-use-type-annotations
- id: text-unicode-replacement-char
- repo: https://github.com/asottile/reorder-python-imports
rev: v3.12.0
hooks:
- id: reorder-python-imports
args: [--py38-plus, --add-import, 'from __future__ import annotations']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
rev: v0.3.3
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/dosisod/refurb
rev: v1.27.0
rev: v2.0.0
hooks:
- id: refurb
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
rev: 0.7.1
hooks:
- id: nbstripout
- repo: https://github.com/executablebooks/mdformat
Expand All @@ -54,7 +49,7 @@ repos:
hooks:
- id: codespell
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.8.0'
rev: 'v1.9.0'
hooks:
- id: mypy
args: [
Expand Down
26 changes: 16 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,38 +81,36 @@ no_implicit_optional = true
warn_redundant_casts = true
warn_unused_ignores = true


[[tool.mypy.overrides]]
module = "tests.*"
disallow_untyped_defs = false
ignore_errors = true


[tool.ruff]
target-version = "py38"
select = ["ALL"]
fix = true
unsafe-fixes = true

[tool.ruff.lint]
extend-ignore = [
"I", # ignore isort
"TRY", # ignore tryceratops.
"TCH", # ignore non-guarded type imports.
# Others.
"ANN101", # type annotating self
"ANN102", # type annotating cls
"ANN401", # flake8-annotate typing.Any
"COM812", # Comply with ruff-format.
"ISC001", # Comply with ruff-format.
]
select = ["ALL"]


[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/*" = ["D", "ANN", "PLR2004", "S101"]

[tool.ruff.lint.isort]
force-single-line = true

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "numpy"


[tool.pytest.ini_options]
# Do not add src since it messes with the loading of pytask-parallel as a plugin.
testpaths = ["tests"]
Expand All @@ -123,3 +121,11 @@ markers = [
"end_to_end: Flag for tests that cover the whole program.",
]
norecursedirs = [".idea", ".tox"]

[tool.coverage.report]
exclude_also = [
"pragma: no cover",
"if TYPE_CHECKING.*:",
"\\.\\.\\.",
"def __repr__",
]
1 change: 1 addition & 0 deletions src/pytask_parallel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Contains the main namespace of the package."""

from __future__ import annotations

try:
Expand Down
1 change: 1 addition & 0 deletions src/pytask_parallel/backends.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Configures the available backends."""

from __future__ import annotations

import enum
Expand Down
2 changes: 2 additions & 0 deletions src/pytask_parallel/build.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"""Extend the build command."""

from __future__ import annotations

import click
from pytask import EnumChoice
from pytask import hookimpl

from pytask_parallel.backends import PARALLEL_BACKENDS_DEFAULT
from pytask_parallel.backends import ParallelBackend

Expand Down
2 changes: 2 additions & 0 deletions src/pytask_parallel/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
"""Configure pytask."""

from __future__ import annotations

import enum
import os
from typing import Any

from pytask import hookimpl

from pytask_parallel.backends import ParallelBackend


Expand Down
30 changes: 18 additions & 12 deletions src/pytask_parallel/execute.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
"""Contains code relevant to the execution."""

from __future__ import annotations

import inspect
import sys
import time
import warnings
from concurrent.futures import Future
from functools import partial
from pathlib import Path
from types import ModuleType
from types import TracebackType
from typing import TYPE_CHECKING
from typing import Any
from typing import Callable

import cloudpickle
from attrs import define
from attrs import field
from pytask import console
from pytask import ExecutionReport
from pytask import get_marks
from pytask import hookimpl
from pytask import Mark
from pytask import parse_warning_filter
from pytask import PNode
from pytask import PTask
from pytask import PythonNode
from pytask import remove_internal_traceback_frames_from_exc_info
from pytask import Session
from pytask import Task
from pytask import warning_record_to_str
from pytask import WarningReport
from pytask import console
from pytask import get_marks
from pytask import hookimpl
from pytask import parse_warning_filter
from pytask import remove_internal_traceback_frames_from_exc_info
from pytask import warning_record_to_str
from pytask.tree_util import PyTree
from pytask.tree_util import tree_leaves
from pytask.tree_util import tree_map
from pytask.tree_util import tree_structure
from rich.traceback import Traceback

from pytask_parallel.backends import PARALLEL_BACKENDS
from pytask_parallel.backends import ParallelBackend
from rich.console import ConsoleOptions
from rich.traceback import Traceback

if TYPE_CHECKING:
from concurrent.futures import Future
from pathlib import Path
from types import ModuleType
from types import TracebackType

from rich.console import ConsoleOptions


@hookimpl
Expand Down
3 changes: 2 additions & 1 deletion src/pytask_parallel/logging.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Contains code relevant to logging."""

from __future__ import annotations

from pytask import Session
from pytask import console
from pytask import hookimpl
from pytask import Session


@hookimpl(trylast=True)
Expand Down
8 changes: 7 additions & 1 deletion src/pytask_parallel/plugin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
"""Entry-point for the plugin."""

from __future__ import annotations

from pluggy import PluginManager
from typing import TYPE_CHECKING

from pytask import hookimpl

from pytask_parallel import build
from pytask_parallel import config
from pytask_parallel import execute
from pytask_parallel import logging

if TYPE_CHECKING:
from pluggy import PluginManager


@hookimpl
def pytask_add_hooks(pm: PluginManager) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SysPathsSnapshot:
"""A snapshot for sys.path."""

def __init__(self) -> None:
self.__saved = list(sys.path), list(sys.meta_path)
self.__saved = sys.path.copy(), sys.meta_path.copy()

def restore(self) -> None:
sys.path[:], sys.meta_path[:] = self.__saved
Expand All @@ -26,7 +26,7 @@ class SysModulesSnapshot:

def __init__(self, preserve: Callable[[str], bool] | None = None) -> None:
self.__preserve = preserve
self.__saved = dict(sys.modules)
self.__saved = sys.modules.copy()

def restore(self) -> None:
if self.__preserve:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import textwrap

import pytest
from pytask import build
from pytask import ExitCode
from pytask import build
from pytask_parallel.backends import ParallelBackend


Expand Down
2 changes: 1 addition & 1 deletion tests/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from time import time

import pytest
from pytask import ExitCode
from pytask import build
from pytask import cli
from pytask import ExitCode
from pytask_parallel.backends import PARALLEL_BACKENDS
from pytask_parallel.backends import ParallelBackend
from pytask_parallel.execute import _Sleeper
Expand Down
6 changes: 3 additions & 3 deletions tests/test_jupyter/test_functional_interface.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "12bc75b1",
"id": "0",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -18,7 +18,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "29ac7311",
"id": "1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -39,7 +39,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "738c9418",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "12bc75b1",
"id": "0",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -18,7 +18,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "29ac7311",
"id": "1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -39,7 +39,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "738c9418",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand Down