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

Working in python 3.12 #373

Merged
merged 4 commits into from
Dec 18, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macOS-latest, windows-latest ]
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ]
defaults:
run:
shell: bash
Expand All @@ -30,15 +30,16 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- uses: snok/install-poetry@v1.3.1
- uses: snok/install-poetry@v1
with:
version: 1.3.1
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install dependencies
run: |
poetry config experimental.new-installer false
poetry config virtualenvs.in-project true
poetry install --no-interaction
poetry install --no-interaction --without dev --without docs

- name: Run tests with Ward
run: |
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ repos:
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/asottile/yesqa
Expand Down
909 changes: 429 additions & 480 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ click-default-group = "^1.2.2"
click-completion = "^0.5.2"
pluggy = ">=0.13.1,<2.0.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pre-commit = "^2.13.0"

[tool.poetry.group.docs.dependencies]
Sphinx = "^3.5.1"
sphinx-rtd-theme = "^0.5.1"

[tool.poetry.group.test.dependencies]
coverage = {version = "^5.1", extras = ["toml"]}
pre-commit = "^2.13.0"

[tool.poetry.scripts]
ward = "ward._run:run"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ def _(module_name=each("test_apples", "apples"), rv=each(True, False)):


class StubModuleFinder:
def find_module(self, module_name: str):
def find_spec(self, module_name: str):
return StubSourceFileLoader()


@dataclass
class StubSourceFileLoader:
path: Path = PATH
origin: Path = PATH


@fixture
Expand Down
6 changes: 3 additions & 3 deletions ward/_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import pkgutil
import sys
from dataclasses import dataclass
from distutils.sysconfig import get_python_lib
from importlib._bootstrap import ModuleSpec # type: ignore[import]
from importlib._bootstrap_external import FileFinder # type: ignore[import]
from pathlib import Path
from sysconfig import get_path
from types import ModuleType
from typing import Callable, Iterable, List, Optional, Set, Tuple

Expand All @@ -27,7 +27,7 @@ def is_test_module(module: pkgutil.ModuleInfo) -> bool:


def _get_module_path(module: pkgutil.ModuleInfo) -> Path:
return Path(module.module_finder.find_module(module.name).path)
return Path(module.module_finder.find_spec(module.name).origin)


def _is_excluded_module(module: pkgutil.ModuleInfo, exclusions: Iterable[str]) -> bool:
Expand Down Expand Up @@ -113,7 +113,7 @@ def get_info_for_modules(

# ignore site-packages directories
abs_path = dir_path.absolute()
if str(abs_path).startswith(get_python_lib()):
if str(abs_path).startswith(get_path("platlib")):
continue

# if we have seen this path before, skip it
Expand Down
4 changes: 2 additions & 2 deletions ward/_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from typing import Any, Dict, Iterable, Optional, Union
from typing import Any, Dict, Iterable, MutableMapping, Optional, Union

import click
import tomli
Expand Down Expand Up @@ -91,7 +91,7 @@ def set_defaults_from_config(
context: click.Context,
param: click.Parameter,
value: Union[str, int],
) -> Dict[str, Any]:
) -> MutableMapping[str, Any]:
paths_supplied_via_cli = context.params.get("path")

search_paths = paths_supplied_via_cli
Expand Down