Skip to content

Commit

Permalink
108 support python 311 (#155)
Browse files Browse the repository at this point in the history
* Support 3.11, Switch to Python 3.11 for dev

* Pass tests and update schema creation script line

* Add sensible coverage exclusions
  • Loading branch information
nathanjmcdougall authored Jan 9, 2025
1 parent 10fdb08 commit 2c57e2f
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.12, 3.13]
python-version: [3.11, 3.12, 3.13]
resolution: [highest, lowest-direct]
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12.4
3.11.11
13 changes: 12 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ license = { file = "LICENSE" }
authors = [
{ name = "Nathan McDougall", email = "[email protected]" },
]
requires-python = ">=3.12"
requires-python = ">=3.11"
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Topic :: Software Development",
Expand Down Expand Up @@ -110,6 +111,16 @@ filterwarnings = [ "error" ]
source = [ "src" ]
omit = [ "*/pytest-of-*/*" ]

[tool.coverage.report]
exclude_also = [
"if TYPE_CHECKING:",
"raise AssertionError",
"raise NotImplementedError",
"assert_never(.*)",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]

[tool.uv]
default-groups = [ "test", "dev" ]

Expand Down
4 changes: 2 additions & 2 deletions src/usethis/_integrations/bitbucket/anchor.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Literal
from typing import Literal, TypeAlias

from pydantic import BaseModel

# N.B. at the point where we support more than one script item, we should create a
# canonical sort order for them and enforce it when we add them to the pipeline.
type ScriptItemName = Literal["install-uv"]
ScriptItemName: TypeAlias = Literal["install-uv"]


class ScriptItemAnchor(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_integrations/bitbucket/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# filename: schema.json
# timestamp: 2025-01-08T09:46:09+00:00
# using the command:
# datamodel-codegen --input tests\usethis\_integrations\bitbucket\schema.json --input-file-type jsonschema --output src\usethis\_integrations\bitbucket\schema.py --enum-field-as-literal all --field-constraints --use-double-quotes --use-union-operator --use-standard-collections --use-default-kwarg --output-model-type pydantic_v2.BaseModel --target-python-version 3.12
# datamodel-codegen --input tests\usethis\_integrations\bitbucket\schema.json --input-file-type jsonschema --output src\usethis\_integrations\bitbucket\schema.py --enum-field-as-literal all --field-constraints --use-double-quotes --use-union-operator --use-standard-collections --use-default-kwarg --output-model-type pydantic_v2.BaseModel --target-python-version 3.11
# ruff: noqa: ERA001
# pyright: reportGeneralTypeIssues=false
# plus manually add Definitions.scripts for type hinting
Expand Down
2 changes: 1 addition & 1 deletion src/usethis/_integrations/pre_commit/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# filename: schema.json
# timestamp: 2024-12-13T02:06:43+00:00
# using the command:
# datamodel-codegen --input tests\usethis\_integrations\pre_commit\schema.json --input-file-type jsonschema --output src\usethis\_integrations\pre_commit\schema.py --enum-field-as-literal all --field-constraints --use-double-quotes --use-union-operator --use-standard-collections --use-default-kwarg --output-model-type pydantic_v2.BaseModel --target-python-version 3.12
# datamodel-codegen --input tests\usethis\_integrations\pre_commit\schema.json --input-file-type jsonschema --output src\usethis\_integrations\pre_commit\schema.py --enum-field-as-literal all --field-constraints --use-double-quotes --use-union-operator --use-standard-collections --use-default-kwarg --output-model-type pydantic_v2.BaseModel --target-python-version 3.11
# ruff: noqa: ERA001
# pyright: reportGeneralTypeIssues=false
# plus manually remove default for LocalRepo.repo
Expand Down
5 changes: 3 additions & 2 deletions src/usethis/_integrations/pydantic/dump.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from functools import singledispatch
from itertools import zip_longest
from typing import TypeAlias

from pydantic import BaseModel, RootModel

type ModelLiteral = bool | int | float | str
type ModelRepresentation = (
ModelLiteral: TypeAlias = bool | int | float | str
ModelRepresentation: TypeAlias = (
ModelLiteral
| dict[str, "ModelRepresentation"]
| list["ModelRepresentation"]
Expand Down
4 changes: 2 additions & 2 deletions src/usethis/_integrations/yaml/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dataclasses import dataclass
from pathlib import Path
from types import NoneType
from typing import TypeVar
from typing import TypeAlias, TypeVar

import ruamel.yaml
from ruamel.yaml.comments import (
Expand Down Expand Up @@ -35,7 +35,7 @@
T = TypeVar("T")


type YAMLLiteral = (
YAMLLiteral: TypeAlias = (
NoneType
| bool
| float
Expand Down
4 changes: 3 additions & 1 deletion src/usethis/_pipeweld/ops.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import TypeAlias

from pydantic import BaseModel


Expand All @@ -14,4 +16,4 @@ class InsertSuccessor(BaseOperation):
pass


type Instruction = InsertSuccessor | InsertParallel
Instruction: TypeAlias = InsertSuccessor | InsertParallel
2 changes: 1 addition & 1 deletion tests/usethis/_integrations/bitbucket/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def test_matches_schema_store(self):

def test_target_python_version(self):
# If this test fails, we should bump the version in the command in schema.py
assert Path(".python-version").read_text().startswith("3.12")
assert Path(".python-version").read_text().startswith("3.11")
2 changes: 1 addition & 1 deletion tests/usethis/_integrations/pre_commit/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ def test_matches_schema_store(self):

def test_target_python_version(self):
# If this test fails, we should bump the version in the command in schema.py
assert Path(".python-version").read_text().startswith("3.12")
assert Path(".python-version").read_text().startswith("3.11")
Loading

0 comments on commit 2c57e2f

Please sign in to comment.