Skip to content

Commit b17e3ef

Browse files
authored
Merge pull request #7 from Secrus/restore-project
Refresh project
2 parents de4bfbf + 6a8fa0d commit b17e3ef

22 files changed

+485
-572
lines changed

.coveragerc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.flake8

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
[flake8]
2+
min_python_version = 3.7.0
23
max-line-length = 88
3-
ignore = E501, E203, W503
4-
per-file-ignores = __init__.py:F401
4+
ban-relative-imports = true
5+
format-greedy = 1
6+
inline-quotes = double
7+
enable-extensions = TC, TC1
8+
type-checking-exempt-modules = typing, typing-extensions
9+
eradicate-whitelist-extend = ^-.*;
10+
extend-ignore =
11+
# E203: Whitespace before ':'
12+
E203
13+
per-file-ignores =
14+
__init__.py:F401
515
exclude =
616
.git
717
__pycache__

.github/workflows/main.yml

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,74 +11,58 @@ on:
1111
- '**'
1212

1313
jobs:
14-
flake8:
15-
runs-on: ubuntu-latest
16-
steps:
17-
- name: Setup Python
18-
uses: actions/setup-python@v1
19-
with:
20-
python-version: 3.7
21-
architecture: x64
22-
- uses: actions/checkout@master
23-
- name: Install flake8
24-
run: pip install flake8
25-
- name: Run flake8
26-
uses: suo/flake8-github-action@releases/v1
27-
with:
28-
checkName: 'flake8'
29-
env:
30-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31-
32-
black:
33-
runs-on: ubuntu-latest
34-
steps:
35-
- uses: actions/checkout@v1
36-
- name: Run Black
37-
uses: lgeiger/black-action@master
38-
with:
39-
args: --check crashtest/ tests/
40-
4114
tests:
42-
runs-on: ubuntu-latest
15+
name: ${{ matrix.os }} / ${{ matrix.python-version }}
16+
runs-on: ${{ matrix.os }}-latest
4317
strategy:
4418
max-parallel: 4
4519
matrix:
46-
python-version: [3.6, 3.7, 3.8]
20+
os: [Ubuntu, MacOS, Windows]
21+
python-version: [3.7, 3.8, 3.9, "3.10"]
22+
23+
defaults:
24+
run:
25+
shell: bash
26+
4727
steps:
48-
- uses: actions/checkout@v2
28+
- uses: actions/checkout@v3
4929

5030
- name: Set up Python ${{ matrix.python-version }}
51-
uses: actions/setup-python@v1
31+
uses: actions/setup-python@v3
5232
with:
5333
python-version: ${{ matrix.python-version }}
5434

5535
- name: Get full Python version
5636
id: full-python-version
57-
shell: bash
58-
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
37+
run: |
38+
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
5939
6040
- name: Install poetry
61-
shell: bash
6241
run: |
63-
curl -fsS -o get-poetry.py https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py
64-
python get-poetry.py -y
65-
echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH"
42+
curl -sL https://install.python-poetry.org | python - -y
43+
44+
- name: Update PATH
45+
if: ${{ matrix.os != 'Windows' }}
46+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
47+
48+
- name: Update PATH for Windows
49+
if: ${{ matrix.os == 'Windows' }}
50+
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
6651

6752
- name: Configure poetry
68-
shell: bash
69-
run: poetry config virtualenvs.in-project true
53+
run: |
54+
poetry config virtualenvs.in-project true
7055
7156
- name: Set up cache
72-
uses: actions/cache@v2
57+
uses: actions/cache@v3
7358
id: cache
7459
with:
7560
path: .venv
7661
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
7762

7863
- name: Ensure cache is healthy
7964
if: steps.cache.outputs.cache-hit == 'true'
80-
shell: bash
81-
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
65+
run: imeout 10s poetry run pip --version || rm -rf .venv
8266

8367
- name: Install dependencies
8468
shell: bash

.pre-commit-config.yaml

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
repos:
22
- repo: https://github.com/psf/black
3-
rev: stable
3+
rev: 22.6.0
44
hooks:
55
- id: black
66

7-
- repo: https://gitlab.com/pycqa/flake8
8-
rev: 3.7.8
7+
- repo: https://github.com/asottile/yesqa
8+
rev: v1.3.0
9+
hooks:
10+
- id: yesqa
11+
additional_dependencies: &flake8_deps
12+
- flake8-broken-line==0.4.0
13+
- flake8-bugbear==22.7.1
14+
- flake8-comprehensions==3.10.0
15+
- flake8-eradicate==1.2.1
16+
- flake8-quotes==3.3.1
17+
- flake8-simplify==0.19.2
18+
- flake8-tidy-imports==4.8.0
19+
- flake8-type-checking==2.0.3
20+
- flake8-typing-imports==1.12.0
21+
- flake8-use-fstring==1.3
22+
- pep8-naming==0.13.0
23+
24+
- repo: https://github.com/pycqa/flake8
25+
rev: 4.0.1
926
hooks:
1027
- id: flake8
28+
additional_dependencies: *flake8_deps
1129

12-
- repo: https://github.com/pre-commit/mirrors-isort
13-
rev: v4.3.21
30+
- repo: https://github.com/pycqa/isort
31+
rev: 5.10.1
1432
hooks:
1533
- id: isort
16-
additional_dependencies: [toml]
17-
exclude: ^.*/?setup\.py$
34+
args: [--add-import, from __future__ import annotations]
1835

1936
- repo: https://github.com/pre-commit/pre-commit-hooks
2037
rev: v2.3.0
@@ -24,3 +41,24 @@ repos:
2441
- id: end-of-file-fixer
2542
exclude: ^tests/.*/fixtures/.*
2643
- id: debug-statements
44+
45+
- repo: https://github.com/pre-commit/mirrors-mypy
46+
rev: v0.971
47+
hooks:
48+
- id: mypy
49+
pass_filenames: false
50+
additional_dependencies:
51+
- pytest>=7.1.2
52+
53+
- repo: https://github.com/asottile/pyupgrade
54+
rev: v2.37.2
55+
hooks:
56+
- id: pyupgrade
57+
args:
58+
- --py37-plus
59+
60+
- repo: https://github.com/hadialqattan/pycln
61+
rev: v2.0.4
62+
hooks:
63+
- id: pycln
64+
args: [--all]

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Crashtest
22

3+
[![Tests](https://github.com/sdispater/crashtest/actions/workflows/tests.yml/badge.svg)](https://github.com/sdispater/crashtest/actions/workflows/tests.yml)
4+
[![PyPI version](https://img.shields.io/pypi/v/crashtest)](https://pypi.org/project/crashtest/)
5+
36
Crashtest is a Python library that makes exceptions handling and inspection easier.

crashtest/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
from __future__ import annotations
2+
3+
14
__version__ = "0.3.1"
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from typing import List
1+
from __future__ import annotations
22

3-
from .solution import Solution
3+
from crashtest.contracts.solution import Solution
44

55

66
class BaseSolution(Solution):
7-
def __init__(self, title: str = None, description: str = None) -> None:
7+
def __init__(self, title: str = "", description: str = "") -> None:
88
self._title = title
99
self._description = description
10-
self._links = []
10+
self._links: list[str] = []
1111

1212
@property
1313
def solution_title(self) -> str:
@@ -18,5 +18,5 @@ def solution_description(self) -> str:
1818
return self._description
1919

2020
@property
21-
def documentation_links(self) -> List[str]:
21+
def documentation_links(self) -> list[str]:
2222
return self._links
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
from typing import List
1+
from __future__ import annotations
22

3-
from .solution import Solution
3+
from typing import TYPE_CHECKING
4+
5+
6+
if TYPE_CHECKING:
7+
from crashtest.contracts.solution import Solution
48

59

610
class HasSolutionsForException:
711
def can_solve(self, exception: Exception) -> bool:
812
raise NotImplementedError()
913

10-
def get_solutions(self, exception: Exception) -> List[Solution]:
14+
def get_solutions(self, exception: Exception) -> list[Solution]:
1115
raise NotImplementedError()

crashtest/contracts/provides_solution.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
from .solution import Solution
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING
4+
5+
6+
if TYPE_CHECKING:
7+
from crashtest.contracts.solution import Solution
28

39

410
class ProvidesSolution:

crashtest/contracts/solution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List
1+
from __future__ import annotations
22

33

44
class Solution:
@@ -11,5 +11,5 @@ def solution_description(self) -> str:
1111
raise NotImplementedError()
1212

1313
@property
14-
def documentation_links(self) -> List[str]:
14+
def documentation_links(self) -> list[str]:
1515
raise NotImplementedError()

0 commit comments

Comments
 (0)