Skip to content

Commit

Permalink
Move operation schema to QREF repo (#1)
Browse files Browse the repository at this point in the history
* Add basic pyproject.toml using Poetry

* Add linters/formatters/static anaylysis tools to dev dependencies

* Add gitignore file

* Add initial version of HQAR models and schema generation functions

* Configure default options for linters and pre-commit

* Format _operation_v1.py

* Add initial version of gh workflow

* Fix maximum Python version in workflow file

* Dummy commit to verify workflows work

* Fix formatting

* Fix typing issue

* Rename DocumentRootV1 to SchemaV1

---------

Co-authored-by: Konrad Jałowiecki <kjalowiecki@psiquantum.com>
  • Loading branch information
2 people authored and mstechly committed Apr 24, 2024
1 parent 01afbff commit 057b8fb
Show file tree
Hide file tree
Showing 11 changed files with 1,502 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[flake8]
max-line-length: 100
docstring-convention = google
ignore =
# Allow continuation line under-indented for visual indent.
E128,
# line contains XXX.
T102,
# Missing docstring in magic method.
D105,
# Missing docstring in __init__.
D107,
# Missing "Returns" in Docstring.
DAR201,
# 1 blank line required between summary line and description.
D205,
# Multi-line docstring summary should start at the first line.
D212,
# The docstring is missing an exception raised.
DAR401,
# The docstring describes an exception not explicitly raised.
DAR402,
# Line break after the binary operator
W504
per-file-ignores =
tests/**/test_*.py:D103,D102,D101
__init__.py:F401

40 changes: 40 additions & 0 deletions .github/workflows/quality_checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Tests and quality checks
on: [pull_request]

jobs:
run_tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies and the package
run: |
python -m pip install --upgrade pip poetry
poetry install
- name: Run unit tests
run: poetry run pytest

run_quality_checks:
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- uses: actions/checkout@v2
- name: Setup poetry
uses: abatilo/actions-poetry@v2
- name:
run: |
poetry install
pip install pre-commit
pre-commit install
pre-commit run -a
- name: Run mypy
run: MYPYPATH=src poetry run mypy --install-types --non-interactive src
161 changes: 161 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# 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/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

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

# 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
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .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

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__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/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
default_language_version:
python: python3

default_stages: [commit, push]

repos:
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files", "--check"]

- repo: https://github.com/ambv/black
rev: 23.1.0
hooks:
- id: black
args: ["--check"]

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8

Loading

0 comments on commit 057b8fb

Please sign in to comment.