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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ jobs:
- "3.11"
- "3.12"
- "3.13"
- "pypy3.10"
- "3.14"
- "pypy3.11"
include:
- os: macos-latest
python: "3.8"
Expand Down
19 changes: 14 additions & 5 deletions dwasfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@
DOCS_REQUIREMENTS = "-rrequirements/requirements-docs.txt"
TEST_REQUIREMENTS = "-rrequirements/requirements-test.txt"
TYPES_REQUIREMENTS = "-rrequirements/requirements-types.txt"
SUPPORTED_PYTHONS = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.10"]
SUPPORTED_PYTHONS = [
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
"3.13",
"3.14",
"pypy3.11",
]
OLDEST_SUPPORTED_PYTHON = SUPPORTED_PYTHONS[0]
PYTHON_FILES = [
"docs/conf.py",
Expand All @@ -31,13 +40,13 @@
# Formatting
##
dwas.register_managed_step(
dwas.predefined.unimport(),
dwas.predefined.unimport(files=PYTHON_FILES),
description="Show which imports are unnecessary",
)
dwas.register_managed_step(dwas.predefined.isort(files=PYTHON_FILES))
dwas.register_managed_step(
dwas.predefined.docformatter(files=PYTHON_FILES),
dependencies=["docformatter[tomli]<1.7.1"],
dependencies=["docformatter[tomli]"],
)
dwas.register_managed_step(dwas.predefined.black())
dwas.register_step_group(
Expand All @@ -47,6 +56,7 @@
# With auto fix
dwas.register_managed_step(
dwas.predefined.unimport(
files=PYTHON_FILES,
additional_arguments=["--diff", "--remove", "--check", "--gitignore"],
),
name="unimport:fix",
Expand All @@ -68,7 +78,7 @@
),
name="docformatter:fix",
run_by_default=False,
dependencies=["docformatter[tomli]<1.7.1"],
dependencies=["docformatter[tomli]"],
requires=["isort:fix"],
)
dwas.register_managed_step(
Expand All @@ -83,7 +93,6 @@
additional_arguments=["check", "--fix", "--show-fixes", "--fix-only"],
),
dependencies=["ruff"],
python=OLDEST_SUPPORTED_PYTHON,
name="ruff:fix",
requires=["black:fix"],
run_by_default=False,
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Testing",
Expand Down
15 changes: 11 additions & 4 deletions src/dwas/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ def flush(

class StreamHandler(io.TextIOWrapper):
def __init__(
self, var: ContextVar[TextIO], log_var: ContextVar[TextIO]
self,
var: ContextVar[TextIO],
log_var: ContextVar[TextIO],
fileno: int,
) -> None:
self._var = var
self._log_var = log_var
self._fileno = fileno

def read(self, size: int | None = None) -> str: # noqa: ARG002
raise io.UnsupportedOperation("can't read from a memorypipe")
Expand All @@ -117,16 +121,19 @@ def flush(self) -> None:
fd.flush()
self._var.get().flush()

def fileno(self) -> int:
return self._fileno


@contextmanager
def instrument_streams() -> Generator[None, None, None]:
STDOUT.set(sys.stdout)
STDERR.set(sys.stderr)
LOG_FILE.set(NoOpWriter())

with redirect_stdout(StreamHandler(STDOUT, LOG_FILE)), redirect_stderr(
StreamHandler(STDERR, LOG_FILE)
):
with redirect_stdout(
StreamHandler(STDOUT, LOG_FILE, sys.stdout.fileno())
), redirect_stderr(StreamHandler(STDERR, LOG_FILE, sys.stderr.fileno())):
yield


Expand Down
2 changes: 1 addition & 1 deletion src/dwas/_steps/parametrize.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def build_parameters(**kwargs: Any) -> Callable[[T], T]:


def extract_parameters(
func: Callable[..., Any]
func: Callable[..., Any],
) -> list[tuple[str, dict[str, Any]]]:
defaults = getattr(func, _DEFAULTS, {})

Expand Down
13 changes: 5 additions & 8 deletions src/dwas/_steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,9 @@ def setup_dependent(
Run some logic into a dependent step.

:param original_step: The original step handler that was used
when the step defining this method was
called.
when the step defining this method was called.
:param current_step: The current step handler, that contains the
context of the step that is going to be
executed.
context of the step that is going to be executed.
"""


Expand Down Expand Up @@ -352,11 +350,10 @@ def gather_artifacts(self, step: StepRunner) -> dict[str, list[Any]]:
Gather all artifacts exposed by this step.

:param step: The step handler that was used when running the
step.
step.
:return: A dictionary of artifact key to a list of arbitrary
data. This **must** return a list, as they are merged
with other steps' artifacts into a single list per
artifact key.
data. This **must** return a list, as they are merged with
other steps' artifacts into a single list per artifact key.
"""


Expand Down
28 changes: 28 additions & 0 deletions tests/predefined/test_docformatter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

import pytest

from .mixins import BaseLinterWithAutofixTest
Expand Down Expand Up @@ -25,3 +27,29 @@ class TestDocformatter(BaseLinterWithAutofixTest):
@pytest.mark.skip("docformatter does not support colored output")
def test_respects_color_settings(self):
pass # pragma: nocover

@pytest.mark.parametrize(
"valid",
(
pytest.param(
True,
id="valid-project",
marks=pytest.mark.xfail(
sys.version_info >= (3, 14),
reason="docformatter does not support python3.14 yet",
strict=True,
),
),
pytest.param(False, id="invalid-project"),
),
)
def test_simple_behavior(self, cache_path, tmp_path, valid):
return super().test_simple_behavior(cache_path, tmp_path, valid)

@pytest.mark.xfail(
sys.version_info >= (3, 14),
reason="docformatter does not support python3.14 yet",
strict=True,
)
def test_can_apply_fixes(self, cache_path, tmp_path):
return super().test_can_apply_fixes(cache_path, tmp_path)
Loading