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

Fix compatibility with Python 3.9 #14

Merged
merged 4 commits into from
Sep 27, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: linting
on:
push:
branches:
- devel
- master
- stable
pull_request:
branches:
- devel
- master
- stable

jobs:
setup:
Expand All @@ -23,6 +23,9 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/setup-python@v4
with:
# TODO: Remove explicit Python version once bug with .python-version file is solved
# https://github.com/actions/setup-python/issues/734
python-version: '3.11'
cache: 'poetry'
- name: Install dependencies
if: steps.python.outputs.cache-hit != 'true'
Expand All @@ -41,6 +44,9 @@ jobs:
id: python
uses: actions/setup-python@v4
with:
# TODO: Remove explicit Python version once bug with .python-version file is solved
# https://github.com/actions/setup-python/issues/734
python-version: '3.11'
cache: 'poetry'
- name: Install dependencies
run: |
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@ name: testing
on:
push:
branches:
- devel
- master
- stable
pull_request:
branches:
- devel
- master
- stable

jobs:
setup:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- name: Install poetry
Expand All @@ -23,6 +27,7 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install dependencies
if: steps.python.outputs.cache-hit != 'true'
Expand All @@ -32,6 +37,10 @@ jobs:
test:
needs: setup
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- name: Install poetry
Expand All @@ -41,6 +50,7 @@ jobs:
id: python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install package
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# dependencies
# environments
.venv/
.tox/

# packaging
dist/
Expand Down
2 changes: 2 additions & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
3.11
3.10
3.9
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## v1.3.0 (unreleased)
OmeGak marked this conversation as resolved.
Show resolved Hide resolved

- Added support for `.header.yml` config files.
- Fixed compatibility with Python 3.9.

## v1.2.0

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ unbehead:
unbehead --check

.PHONY: lint
lint: mypy ruff unbehead
lint: ruff unbehead mypy

# -- testing -------------------------------------------------------------------

Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ git clone https://github.com/unconventionaldotdev/unbeheader
cd unbeheader
```

Before creating the virtualenv, you probably want to be using the same version of Python that the development of the project is targeting. This is the version specified in the `.python-version` file and you can install it with `pyenv`:
Before creating the virtualenv, you probably want to be using the same version of Python that the development of the project is targeting. This is the first version specified in the `.python-version` file and you can install it with `pyenv`:

```sh
pyenv install
Expand Down Expand Up @@ -160,14 +160,20 @@ unbehead

This project uses GitHub Actions to run the tests and linter on every pull request to the `master` and `devel` branches. You are still encouraged to run the tests and linter locally before pushing your changes.

Linter checks can be run with:

```sh
poetry run -- make lint
```

Tests can be run with:

```sh
poetry run -- make test
```

Linter can be run with:
Tests can be run against all supported Python versions with:

```sh
poetry run -- make lint
tox
```
142 changes: 136 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[virtualenvs]
create = true
in-project = true
prefer-active-python = true

[tool.poetry]
name = "unbeheader"
Expand Down Expand Up @@ -37,6 +38,7 @@ click = ">=8"
mypy = "^1.5.1"
pytest = "^7.4.0"
ruff = "^0.0.280"
tox = "^4.11.3"
types-pyyaml = "^6.0.12.11"

[build-system]
Expand Down
6 changes: 3 additions & 3 deletions src/unbeheader/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from re import Pattern
from typing import Any
from typing import NamedTuple
from typing import TypeAlias

ConfigDict: TypeAlias = dict[str, Any]
PathCache: TypeAlias = dict[Path, bool]
# TODO: Use explicit TypeAlias when Python 3.9 is dropped
ConfigDict = dict[str, Any]
PathCache = dict[Path, bool]


@dataclass
Expand Down
2 changes: 2 additions & 0 deletions src/unbeheader/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This file is part of Unbeheader.
# Copyright (C) CERN & UNCONVENTIONAL

from __future__ import annotations

import re
from pathlib import Path
from re import Match
Expand Down
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tox]
envlist = py{39,310,311}
no_package = true

[testenv]
allowlist_externals = poetry
commands_pre =
poetry install -v
commands =
poetry run -- make test