Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor for Python 3 #4

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .codespellignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MoT
LINZ
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# EditorConfig: https://EditorConfig.org. Provides sensible defaults for
# non vscode editors.

# top-most EditorConfig file
root = true

# Every file.
[*]
charset = "utf8"
end_of_line = lf
insert_final_newline = true

indent_style = space
indent_size = 4

trim_trailing_whitespace = true

# Python. (Duplicates used as placeholders)
[*.py]
indent_style = space
indent_size = 4
26 changes: 26 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: "linting - all"
on:
pull_request:
push:
branches:
- "main"
jobs:
lint:
name: "linting (python)"
runs-on: "ubuntu-latest"
steps:
- name: "Check out repository"
uses: "actions/checkout@v2"
- name: "Set up Python"
uses: "actions/setup-python@v2"
with:
python-version: "3.10"
- name: "install linting tooling"
continue-on-error: true
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements/local.txt ; pylint **/*.py
- name: "run linting via tox"
run: |
tox -e linting
25 changes: 25 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: pyreleaser
on:
push:
tags:
- '*'
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: "checkout"
uses: actions/checkout@v4
- name: "fetch unshallow"
run: git fetch --prune --unshallow
- name: "list"
run: pwd && ls -la
- name: "deps"
run: python -m pip install -r requirements/local.txt
- name: "package"
run: make package-source
- name: "list"
run: ls -la ./dist/
- name: "release"
uses: ncipollo/[email protected]
with:
artifacts: "dist/*"
57 changes: 57 additions & 0 deletions .github/workflows/unit-tests-all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: "unit tests - all"
on:
pull_request:
push:
branches:
- "main"
jobs:
tox:
name: "Python ${{ matrix.python-version }} -- ${{ matrix.os }} "
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10"]
experimental: [false]
include:
#
# Versions list: https://github.com/actions/python-versions/releases
# Example formatting: 3.11.0-alpha.1, 3.9.0-beta.8, 3.10.0-rc.3
#
- os: ubuntu-latest
python-version: "3.11.0"
experimental: true
- os: macos-latest
python-version: "3.11.0"
experimental: true
steps:
- name: "check out repository"
uses: "actions/checkout@v2"
with:
submodules: 'true'
- name: "set up python ${{ matrix.python-version }}"
uses: "actions/setup-python@v2"
with:
python-version: "${{ matrix.python-version }}"
- name: "get pip cache dir"
id: "pip-cache"
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: "cache pip packages"
uses: "actions/cache@v2"
with:
path: "${{ steps.pip-cache.outputs.dir }}"
key: "${{ runner.os }}-pip-${{ hashFiles('**/base.txt', '**/local.txt') }}"
restore-keys: |
${{ runner.os }}-pip-
- name: "install tox"
run: |
python -m pip install --upgrade pip
pip install tox
- name: "run tox"
env:
TOXENV: py3
run: |
tox
138 changes: 138 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# project specific files
__init__.py
log.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
tar-src/

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# 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

# SageMath parsed files
*.sage.py

# 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/

# Test artefacts
test-args.cfg
sheets/
2 changes: 2 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Configurtion file for Markdown lint. Add exceptions here.
default: true
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: check-json
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-case-conflict
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
language_version: python3
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.270
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.35.0
hooks:
- id: markdownlint
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: ["-I", ".codespellignore"]
- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: python
language_version: python3
args:
[
"-rn", # Only display messages.
"-sn", # Don't display the pylint score.
"--rcfile=.pylintrc"
]
40 changes: 40 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Pylint configuration.
#
# .pylintrc guide: https://github.com/PyCQA/pylint/blob/cfc393a8dff9ec09bd2fcb25857e772ae04a4991/examples/pylintrc
#

[MAIN]
extension-pkg-whitelist=
pydantic, # binary module validation, Pydantic/Pylint recommendation.

ignore=
LICENSE,
.pylintrc,

ignore-patterns=
^(.+).ini$,
^(.+).md$,
^(.+).sh$,
^(.+).service$,
^(.+).json,
^(.+).yml,
^(.+).yaml,
^(.+).toml,
^(.+).html,
^(.+).htm,
^(.+).svg,
^(.+).cfg,
^(.+).prov,
^(.+).notes,
^\.,

ignore-paths=
requirements/.,
tests/fixtures/vcrpy/.,
Makefile,

[MESSAGES CONTROL]

disable =
C0301, # line too long.
R0903, # too few public methods.
Loading