Skip to content

Commit 57e7106

Browse files
authored
linters + tests (#4)
1 parent 1e6ce2e commit 57e7106

22 files changed

+1536
-349
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
indent_style = space
9+
indent_size = 2
10+
11+
[*.py]
12+
indent_size = 4
13+
14+
[*.{md,txt,rst}]
15+
trim_trailing_whitespace = false

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length=120
3+
exclude=.git,*tests*

.github/workflows/lint.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: Lint
3+
4+
on:
5+
pull_request:
6+
branches: [ main ]
7+
8+
jobs:
9+
lint:
10+
runs-on: windows-latest
11+
strategy:
12+
matrix:
13+
python-version:
14+
- "3.7"
15+
- "3.8"
16+
- "3.9"
17+
steps:
18+
-
19+
name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
-
24+
uses: actions/checkout@v2
25+
-
26+
name: dependencies
27+
run: |
28+
python -m pip install poetry==1.1.7
29+
poetry install
30+
-
31+
name: install hooks
32+
run: poetry run pre-commit install-hooks
33+
-
34+
name: flake8
35+
run: poetry run pre-commit run flake8 --all-files --show-diff-on-failure
36+
-
37+
name: pylint
38+
run: poetry run pre-commit run pylint --all-files --show-diff-on-failure
39+
-
40+
name: mypy
41+
run: poetry run pre-commit run mypy --all-files --show-diff-on-failure

.github/workflows/pypi.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: PyPI upload
3+
4+
on:
5+
push:
6+
tags:
7+
- '*'
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
steps:
13+
-
14+
name: Set up Python 3.9
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: "3.9"
18+
-
19+
name: Checkout
20+
uses: actions/checkout@v2
21+
-
22+
name: dependencies
23+
run: |
24+
python -m pip install poetry==1.1.7
25+
-
26+
name: build
27+
run: poetry build
28+
-
29+
name: publish
30+
run: |
31+
poetry config http-basic.pypi ${{ secrets.PYPI_LOGIN }} ${{ secrets.PYPI_PASS }}
32+
poetry publish

.github/workflows/tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Test
3+
4+
on:
5+
pull_request:
6+
branches: [ main ]
7+
8+
jobs:
9+
tests:
10+
runs-on: windows-latest
11+
env:
12+
SOURCES_DIR: sources
13+
strategy:
14+
matrix:
15+
python-version:
16+
- "3.7"
17+
- "3.8"
18+
- "3.9"
19+
steps:
20+
-
21+
name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
-
26+
uses: actions/checkout@v2
27+
-
28+
name: Install dependencies
29+
run: |
30+
python -m pip install poetry==1.1.7
31+
poetry install
32+
-
33+
name: pytest
34+
run: poetry run pytest -vv

.gitignore

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# Robots
2-
log.html
3-
report.html
4-
output.xml
5-
# idea
1+
.html
2+
.xml
63
.idea/
4+
75
# Byte-compiled / optimized / DLL files
86
__pycache__/
97
*.py[cod]
@@ -14,7 +12,6 @@ __pycache__/
1412

1513
# Distribution / packaging
1614
.Python
17-
env/
1815
build/
1916
develop-eggs/
2017
dist/
@@ -26,9 +23,13 @@ lib64/
2623
parts/
2724
sdist/
2825
var/
26+
wheels/
27+
pip-wheel-metadata/
28+
share/python-wheels/
2929
*.egg-info/
3030
.installed.cfg
3131
*.egg
32+
MANIFEST
3233

3334
# PyInstaller
3435
# Usually these files are written by a python script from a template
@@ -43,13 +44,16 @@ pip-delete-this-directory.txt
4344
# Unit test / coverage reports
4445
htmlcov/
4546
.tox/
47+
.nox/
4648
.coverage
4749
.coverage.*
4850
.cache
4951
nosetests.xml
5052
coverage.xml
51-
*,cover
53+
*.cover
54+
*.py,cover
5255
.hypothesis/
56+
.pytest_cache/
5357

5458
# Translations
5559
*.mo
@@ -58,6 +62,8 @@ coverage.xml
5862
# Django stuff:
5963
*.log
6064
local_settings.py
65+
db.sqlite3
66+
db.sqlite3-journal
6167

6268
# Flask stuff:
6369
instance/
@@ -72,24 +78,56 @@ docs/_build/
7278
# PyBuilder
7379
target/
7480

75-
# IPython Notebook
81+
# Jupyter Notebook
7682
.ipynb_checkpoints
7783

84+
# IPython
85+
profile_default/
86+
ipython_config.py
87+
7888
# pyenv
7989
.python-version
8090

81-
# celery beat schedule file
91+
# pipenv
92+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
94+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
95+
# install all needed dependencies.
96+
#Pipfile.lock
97+
98+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
99+
__pypackages__/
100+
101+
# Celery stuff
82102
celerybeat-schedule
103+
celerybeat.pid
83104

84-
# dotenv
85-
.env
105+
# SageMath parsed files
106+
*.sage.py
86107

87-
# virtualenv
108+
# Environments
109+
.env
110+
.venv
111+
env/
88112
venv/
89113
ENV/
114+
env.bak/
115+
venv.bak/
90116

91117
# Spyder project settings
92118
.spyderproject
119+
.spyproject
93120

94121
# Rope project settings
95122
.ropeproject
123+
124+
# mkdocs documentation
125+
/site
126+
127+
# mypy
128+
.mypy_cache/
129+
.dmypy.json
130+
dmypy.json
131+
132+
# Pyre type checker
133+
.pyre/

.pre-commit-config.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
repos:
2+
-
3+
repo: local
4+
hooks:
5+
# -
6+
# id: isort
7+
# name: isort
8+
# entry: isort
9+
# language: system
10+
# files: ^(winregistry|test)/.+\.py$
11+
-
12+
id: black
13+
name: black
14+
entry: black
15+
language: system
16+
files: ^(winregistry|test)/.+\.py$
17+
-
18+
id: flake8
19+
name: flake8
20+
entry: flake8
21+
language: system
22+
files: ^(winregistry|test)/.+\.py$
23+
-
24+
id: pylint
25+
name: pylint
26+
entry: pylint
27+
language: system
28+
files: ^(winregistry|test)/.+\.py$
29+
-
30+
id: mypy
31+
name: mypy
32+
entry: mypy
33+
language: system
34+
files: ^(winregistry|test)/.+\.py$
35+
-
36+
repo: https://github.com/pre-commit/pre-commit-hooks
37+
rev: "v3.4.0"
38+
hooks:
39+
- id: check-added-large-files
40+
- id: check-json
41+
- id: check-merge-conflict
42+
- id: check-yaml
43+
- id: detect-private-key
44+
- id: end-of-file-fixer
45+
- id: requirements-txt-fixer
46+
- id: forbid-new-submodules
47+
- id: trailing-whitespace

mypy.ini

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[mypy]
2+
ignore_missing_imports = True
3+
4+
# Disallow dynamic typing
5+
disallow_any_unimported = False
6+
disallow_any_generics = True
7+
disallow_subclassing_any = False
8+
9+
# Disallow untyped definitions and calls
10+
disallow_untyped_defs = True
11+
disallow_incomplete_defs = True
12+
13+
# None and optional handling
14+
no_implicit_optional = True
15+
16+
# Configuring warnings
17+
warn_unused_ignores = True
18+
warn_return_any = True
19+
warn_redundant_casts = True
20+
21+
# Misc things
22+
strict_equality = True
23+
24+
# Config file
25+
warn_unused_configs = True
26+
27+
[mypy-tests.*]
28+
ignore_errors = True
29+
30+
# ignore return type for routers
31+
[mypy-app.routers.*]
32+
disallow_incomplete_defs = False
33+
disallow_untyped_defs = False
34+
35+
[pydantic-mypy]
36+
init_forbid_extra = True
37+
init_typed = True
38+
warn_required_dynamic_aliases = True
39+
warn_untyped_fields = True

0 commit comments

Comments
 (0)