diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..019facb --- /dev/null +++ b/.coveragerc @@ -0,0 +1,6 @@ +[run] +omit = + # The tests themselves + tests/* + # Any venv files + venv/* diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..49e1306 --- /dev/null +++ b/.flake8 @@ -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 diff --git a/.mypy.ini b/.mypy.ini new file mode 100644 index 0000000..03840fd --- /dev/null +++ b/.mypy.ini @@ -0,0 +1,4 @@ +[mypy] +follow_imports = skip +ignore_missing_imports = True +scripts_are_modules = True diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a8bfb90 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 +### - 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 +- 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 +### - 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' diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..f69abe4 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.9.7 diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..a960986 --- /dev/null +++ b/requirements-dev.txt @@ -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