Skip to content

Commit

Permalink
linters + tests (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
shpaker committed Jul 8, 2021
1 parent 1e6ce2e commit 57e7106
Show file tree
Hide file tree
Showing 22 changed files with 1,536 additions and 349 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

[*.py]
indent_size = 4

[*.{md,txt,rst}]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length=120
exclude=.git,*tests*
41 changes: 41 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: Lint

on:
pull_request:
branches: [ main ]

jobs:
lint:
runs-on: windows-latest
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
steps:
-
name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
-
uses: actions/checkout@v2
-
name: dependencies
run: |
python -m pip install poetry==1.1.7
poetry install
-
name: install hooks
run: poetry run pre-commit install-hooks
-
name: flake8
run: poetry run pre-commit run flake8 --all-files --show-diff-on-failure
-
name: pylint
run: poetry run pre-commit run pylint --all-files --show-diff-on-failure
-
name: mypy
run: poetry run pre-commit run mypy --all-files --show-diff-on-failure
32 changes: 32 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: PyPI upload

on:
push:
tags:
- '*'

jobs:
build:
runs-on: windows-latest
steps:
-
name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: "3.9"
-
name: Checkout
uses: actions/checkout@v2
-
name: dependencies
run: |
python -m pip install poetry==1.1.7
-
name: build
run: poetry build
-
name: publish
run: |
poetry config http-basic.pypi ${{ secrets.PYPI_LOGIN }} ${{ secrets.PYPI_PASS }}
poetry publish
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Test

on:
pull_request:
branches: [ main ]

jobs:
tests:
runs-on: windows-latest
env:
SOURCES_DIR: sources
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
steps:
-
name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
-
uses: actions/checkout@v2
-
name: Install dependencies
run: |
python -m pip install poetry==1.1.7
poetry install
-
name: pytest
run: poetry run pytest -vv
62 changes: 50 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Robots
log.html
report.html
output.xml
# idea
.html
.xml
.idea/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand All @@ -14,7 +12,6 @@ __pycache__/

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
Expand All @@ -26,9 +23,13 @@ lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
Expand All @@ -43,13 +44,16 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
Expand All @@ -58,6 +62,8 @@ coverage.xml
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
Expand All @@ -72,24 +78,56 @@ docs/_build/
# PyBuilder
target/

# IPython Notebook
# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# dotenv
.env
# SageMath parsed files
*.sage.py

# virtualenv
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
repos:
-
repo: local
hooks:
# -
# id: isort
# name: isort
# entry: isort
# language: system
# files: ^(winregistry|test)/.+\.py$
-
id: black
name: black
entry: black
language: system
files: ^(winregistry|test)/.+\.py$
-
id: flake8
name: flake8
entry: flake8
language: system
files: ^(winregistry|test)/.+\.py$
-
id: pylint
name: pylint
entry: pylint
language: system
files: ^(winregistry|test)/.+\.py$
-
id: mypy
name: mypy
entry: mypy
language: system
files: ^(winregistry|test)/.+\.py$
-
repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v3.4.0"
hooks:
- id: check-added-large-files
- id: check-json
- id: check-merge-conflict
- id: check-yaml
- id: detect-private-key
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: forbid-new-submodules
- id: trailing-whitespace
39 changes: 39 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[mypy]
ignore_missing_imports = True

# Disallow dynamic typing
disallow_any_unimported = False
disallow_any_generics = True
disallow_subclassing_any = False

# Disallow untyped definitions and calls
disallow_untyped_defs = True
disallow_incomplete_defs = True

# None and optional handling
no_implicit_optional = True

# Configuring warnings
warn_unused_ignores = True
warn_return_any = True
warn_redundant_casts = True

# Misc things
strict_equality = True

# Config file
warn_unused_configs = True

[mypy-tests.*]
ignore_errors = True

# ignore return type for routers
[mypy-app.routers.*]
disallow_incomplete_defs = False
disallow_untyped_defs = False

[pydantic-mypy]
init_forbid_extra = True
init_typed = True
warn_required_dynamic_aliases = True
warn_untyped_fields = True
Loading

0 comments on commit 57e7106

Please sign in to comment.