Skip to content

Commit

Permalink
feat: Official support for Python 3.12 (#39)
Browse files Browse the repository at this point in the history
* feat: Official support for Python 3.12

* Use `allow-prereleases: true`

* Update pre-commit hooks

* Remove explicit dependency on greenlet

* Use PIP_ONLY_BINARY

* Fix styles

* Use fewer `allow-prereleases`

* Test with x64

* Increase verbosity

* Do not cache dependencies

* Use 3.11 for coverage

* Fix source paths

* Maybe use same arch

* Use `relative_files`

* Use `source`

* Use `[paths]`

* Use wildcard

* Fix typo

* Clean up
  • Loading branch information
edgarrmondragon authored Oct 7, 2023
1 parent be19a9a commit 3f375d5
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.12
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- uses: actions/setup-python@v4
with:
cache: pip
python-version: "3.11"
python-version: "3.12"
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
Expand All @@ -55,7 +55,7 @@ jobs:
- uses: actions/setup-python@v4
with:
cache: pip
python-version: "3.11"
python-version: "3.12"
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
Expand All @@ -78,11 +78,11 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
sqlalchemy-version: ["1", "2"]
include:
- python-version: "3.11"
- python-version: "3.12"
sqlalchemy-version: "2"
os: "windows-latest"

- python-version: "3.11"
- python-version: "3.12"
sqlalchemy-version: "2"
os: "macos-latest"
steps:
Expand All @@ -92,6 +92,7 @@ jobs:
cache: pip
python-version: ${{ matrix.python-version }}
allow-prereleases: true
architecture: x64
- name: Install dependencies
env:
PIP_CONSTRAINT: .github/workflows/constraints.txt
Expand Down
11 changes: 10 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ repos:
rev: v0.0.292
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
args: [--fix, --preview, --exit-non-zero-on-fix, --show-fixes]
- id: ruff
name: Ruff format
entry: ruff format

- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
language_version: python3.11

- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.2.0"
Expand Down
26 changes: 19 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ dynamic = [
"version",
]
dependencies = [
"greenlet>=3.0.0a1",
"sqlalchemy>=1.4",
"sqlean-py>=0.21.5.1",
]
Expand Down Expand Up @@ -71,6 +70,15 @@ dependencies = [
matrix-name-format = "{variable}_{value}"
[tool.hatch.envs.test.env-vars]
SQLALCHEMY_WARN_20 = "1"
[tool.hatch.envs.test.overrides]
env.GITHUB_ACTIONS.dev-mode = { value = false, if = ["true"] }

[[tool.hatch.envs.test.overrides.matrix.sqlalchemy.env-vars]]
key = "PIP_ONLY_BINARY"
value = ":all:"
if = ["2"]
platform = ["macos"]

[tool.hatch.envs.test.scripts]
run = "pytest {args:tests}"
cov = "coverage run -m pytest {args:tests}"
Expand All @@ -86,7 +94,7 @@ dependencies = [
[tool.hatch.envs.coverage.scripts]
json = "coverage json"
xml = "coverage xml"
report = ["coverage combine", "coverage report --show-missing"]
report = ["coverage combine --debug=pathmap", "coverage report --show-missing"]

[tool.hatch.envs.typing]
dependencies = ["mypy>=1.0.0", "pytest"]
Expand All @@ -112,6 +120,7 @@ ignore = [
"ANN102", # missing-type-cls
]
line-length = 100
preview = true
select = [
"F", # Pyflakes
"E", # pycodestyle (error)
Expand Down Expand Up @@ -230,14 +239,17 @@ convention = "google"
[tool.pytest.ini_options]
addopts = ["-vv", "-W error"]

[tool.coverage.paths]
package = [
"src/sqlean_driver/",
"*/site-packages/sqlean_driver/",
]

[tool.coverage.run]
source_pkgs = ["sqlean_driver", "tests"]
branch = true
source = ["sqlean_driver", "tests"]
parallel = true

[tool.coverage.paths]
sqlean_driver = ["src/sqlean_driver", "*/sqlean-driver/src/sqlean_driver"]
tests = ["tests", "*/sqlean-driver/tests"]
relative_files = true

[tool.coverage.report]
exclude_lines = [
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

from __future__ import annotations

import os
from importlib.metadata import version


def pytest_report_header() -> list[str]:
"""Return a list of strings to be displayed in the header of the report."""
pip_env_vars = (f"{var}={value}" for var, value in os.environ.items() if var.startswith("PIP_"))
gh_env_vars = (
f"{var}={value}" for var, value in os.environ.items() if var.startswith("GITHUB_")
)
return [
f"sqlalchemy: {version('sqlalchemy')}",
f"sqlean.py: {version('sqlean.py')}",
f"PIP_*: {','.join(pip_env_vars)}",
f"GITHUB_*: {','.join(gh_env_vars)}",
]

0 comments on commit 3f375d5

Please sign in to comment.