Skip to content

Commit

Permalink
Working in python 3.12 (#373)
Browse files Browse the repository at this point in the history
* Working in python 3.12

* Adjustment of installation of development dependencies

* Removing distutils dependency

* Pipeline
  • Loading branch information
taconi committed Dec 18, 2023
1 parent 1c54620 commit 2523466
Show file tree
Hide file tree
Showing 7 changed files with 448 additions and 494 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build.yml
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
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
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
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
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
@@ -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

0 comments on commit 2523466

Please sign in to comment.