Initial setup for proper development with linting etc

This commit is contained in:
Athanasius 2021-11-04 11:58:38 +00:00
parent 930632b0e9
commit 15e385287a
No known key found for this signature in database
GPG Key ID: 8C392035DD80FD62
6 changed files with 170 additions and 0 deletions

6
.coveragerc Normal file
View File

@ -0,0 +1,6 @@
[run]
omit =
# The tests themselves
tests/*
# Any venv files
venv/*

43
.flake8 Normal file
View File

@ -0,0 +1,43 @@
[flake8]
# Show exactly where in a line the error happened
#show-source = True
max-line-length = 120
# Add _ as a builtin for localisation stuff
builtins = _
# check syntax in doctests
doctests = True
max-complexity = 15
per-file-ignores = ./EDMC.py:E402
# Plugin configs
# required plugins:
# https://github.com/Melevir/flake8-cognitive-complexity
# Provides cognitive complexity checking
# https://github.com/adamchainz/flake8-comprehensions
# Checks list/dict/set/* comprehensions for simplification or replacement
# https://github.com/PyCQA/pep8-naming
# checks names against PEP8 rules (eg CamelCase for class names)
# https://github.com/best-doctor/flake8-annotations-coverage
# Checks code for type annotations
# https://pypi.org/project/flake8-isort/
# Ensures imports are well sorted
# https://pypi.org/project/flake8-noqa/
# Ensures that noqa statements are correctly formed
# https://github.com/MichaelKim0407/flake8-use-fstring
# Prefers fstrings over .format and modulo based formatters
max-cognitive-complexity = 15
# require that all noqa directves disable specific errors
noqa-require-code = True
docstring-convention = numpy

4
.mypy.ini Normal file
View File

@ -0,0 +1,4 @@
[mypy]
follow_imports = skip
ignore_missing_imports = True
scripts_are_modules = True

84
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,84 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v3.4.0'
hooks:
- id: check-merge-conflict
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
#- repo: https://github.com/pre-commit/mirrors-autopep8
# rev: ''
# hooks:
# - id: autopep8
### # flake8 --show-source <file>
### - repo: https://gitlab.com/pycqa/flake8
### rev: ''
### hooks:
### - id: flake8
#
# Try using local flake8
- repo: local
hooks:
- id: flake8
name: flake8
entry: flake8
language: system
types: [ python ]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: 'v1.8.0'
hooks:
- id: python-no-eval
- id: python-no-log-warn
# This is a pain where a comment begins with the word 'type' otherwise
# - id: python-use-type-annotations
# mypy - static type checking
# mypy --follow-imports skip <file>
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.812'
hooks:
- id: mypy
args: [ "--follow-imports", "skip", "--ignore-missing-imports", "--scripts-are-modules" ]
### # pydocstyle.exe <file>
### - repo: https://github.com/FalconSocial/pre-commit-mirrors-pep257
### rev: ''
### hooks:
### - id: pep257 # docstring conventions
### # Alternate https://github.com/PyCQA/pydocstyle
# - repo: https://github.com/digitalpulp/pre-commit-php
# rev: ''
# hooks:
# -id: php-unit
# safety.exe check -r requirements.txt
- repo: https://github.com/Lucas-C/pre-commit-hooks-safety
rev: 'v1.2.1'
hooks:
- id: python-safety-dependencies-check
entry: safety
args: [check, --bare, -r]
language: system
# Check translation comments are up to date
- repo: local
hooks:
- id: LANG_comments
name: 'LANG comments'
language: system
entry: python scripts/find_localised_strings.py --compare-lang L10n/en.template --directory . --ignore coriolis-data --ignore dist.win32
pass_filenames: false
always_run: true
default_language_version:
python: python3.9
default_stages: [ commit, push ]
#files: '([^\.].+/)*.py'

1
.python-version Normal file
View File

@ -0,0 +1 @@
3.9.7

32
requirements-dev.txt Normal file
View File

@ -0,0 +1,32 @@
# So that you don't get warnings like:
# Using legacy 'setup.py install' for flake8-annotations-coverage, since package 'wheel' is not installed.
wheel
# Static analysis tools
flake8==4.0.1
flake8-annotations-coverage==0.0.5
flake8-cognitive-complexity==0.1.0
flake8-comprehensions==3.7.0
flake8-docstrings==1.6.0
isort==5.10.0
flake8-isort==4.1.1
flake8-json==21.7.0
flake8-noqa==1.2.0
flake8-polyfill==1.0.2
flake8-use-fstring==1.3
mypy==0.910
pep8-naming==0.12.1
safety==1.10.3
types-requests==2.25.11
# Code formatting tools
autopep8==1.6.0
# Testing
pytest==6.2.5
pytest-cov==3.0.0 # Pytest code coverage support
coverage[toml]==6.1.1 # pytest-cov dep. This is here to ensure that it includes TOML support for pyproject.toml configs
# All of the normal requirements
-r requirements.txt