diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..f256119 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,8 @@ +[bumpversion] +current_version = 0.1.0 +commit = False +allow_dirty = True + +[bumpversion:file:pyproject.toml] +search = version = "{current_version}" +replace = version = "{new_version}" diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..7e2f228 --- /dev/null +++ b/.flake8 @@ -0,0 +1,23 @@ +[flake8] +max-line-length=100 +docstring-convention=all +import-order-style=pycharm +application-import-names=dropmate_py,tests +extend-ignore= + P102,B311,W503,E203,E226,S311, + # Missing Docstrings + D100,D104,D105,D107, + # Docstring Whitespace + D203,D212,D214,D215, + # Docstring Quotes + D301,D302, + # Docstring Content + D400,D401,D402,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414,D416,D417, + # Type Annotations + ANN002,ANN003,ANN101,ANN102,ANN204,ANN206, + # pep8-naming + N802,N806,N815, +extend-exclude= + .venv, +per-file-ignores = + tests/test_*.py:D103 E501, diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..31cfc91 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: sco1 diff --git a/.github/workflows/lint_test.yml b/.github/workflows/lint_test.yml new file mode 100644 index 0000000..ab7dc38 --- /dev/null +++ b/.github/workflows/lint_test.yml @@ -0,0 +1,108 @@ +name: lint-and-test + +on: + pull_request: + push: + branches: + - main + tags-ignore: + - "**" # Skip re-linting when tags are added + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Install Poetry for caching + run: pipx install poetry + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + cache: 'poetry' + + - name: Install dependencies + run: | + python -m pip install -U pip setuptools importlib-metadata + pip install poetry + poetry install + + - name: Run mypy + run: poetry run mypy . + if: always() + + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11", "3.12-dev"] + fail-fast: false + + steps: + - uses: actions/checkout@v3 + - name: Install Poetry for caching + run: pipx install poetry + + - name: Set up (release) Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + if: "!endsWith(matrix.python-version, '-dev')" + with: + python-version: ${{ matrix.python-version }} + cache: 'poetry' + + - name: Set up (deadsnakes) Python ${{ matrix.python-version }} + uses: deadsnakes/action@v3.0.0 + if: endsWith(matrix.python-version, '-dev') + with: + python-version: ${{ matrix.python-version }} + cache: 'poetry' + + - name: Install dependencies + run: | + python -m pip install -U pip setuptools importlib-metadata + pip install tox-gh-actions + + - name: Run tests w/tox + run: tox + + - name: Cache coverage for ${{ matrix.python-version }} + uses: actions/upload-artifact@v3 + with: + name: cov_py${{ matrix.python-version }} + path: .coverage + + combine-cov: + runs-on: ubuntu-latest + needs: test + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Pull coverage workflow artifacts + uses: actions/download-artifact@v3 + with: + path: cov_cache/ + + - name: Install cov & combine + run: | + pip install coverage + coverage combine ./cov_cache/**/.coverage + + - name: Report coverage + run: | + echo '**Combined Coverage**' >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + coverage report -m --skip-covered >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + coverage html + + - name: Publish cov HTML + uses: actions/upload-artifact@v3 + with: + path: htmlcov/ + name: cov_report_html diff --git a/.github/workflows/pypi_release.yml b/.github/workflows/pypi_release.yml new file mode 100644 index 0000000..0ca3048 --- /dev/null +++ b/.github/workflows/pypi_release.yml @@ -0,0 +1,29 @@ +name: Publish to PyPI + +on: + release: + types: [published] + +jobs: + build: + name: Build dist & publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install build dependencies & build + run: | + python -m pip install --upgrade pip + pip install poetry + poetry build + + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1.5 + with: + user: __token__ + password: ${{ secrets.pypi_api_token }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b9e3b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,48 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# Packaging +*.egg-info/ +build/ +dist/ + +# Jupyter +.ipynb_checkpoints +*.ipynb + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +.python-version + +# jetbrains +.idea/ +.DS_Store + +# vscode +.vscode + +# logs +*.log +test-*.xml + +# Unit test / coverage reports +.coverage +.tox +.coverage.* +coverage.xml +cov.xml +htmlcov +.pytest_cache/ + +# mypy +.mypy_cache/ + +sample_data/ \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..69abd1a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,40 @@ +ci: + autoupdate_schedule: monthly + +repos: + - 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 + name: isort + - repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + additional_dependencies: + - flake8-annotations + - flake8-bugbear + - flake8-docstrings + - flake8-fixme + - pep8-naming + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-case-conflict + - id: check-json + - id: check-merge-conflict + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 + hooks: + - id: python-check-blanket-noqa + - id: python-check-blanket-type-ignore + - id: python-use-type-annotations diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3a878d5 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,2 @@ +# Changelog +Versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (``.``.``) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c6a87bd --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 - Present S. Co1 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..a8d7659 --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Dropmate-py +[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit) +[![Code style: black](https://img.shields.io/badge/code%20style-black-black)](https://github.com/psf/black) + +Python helpers for the [EDC Dropmate](https://earthlydynamics.com/dropmate/). diff --git a/dropmate_py/__init__.py b/dropmate_py/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..232e912 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,68 @@ +[tool.poetry] +name = "dropmate-py" +version = "0.1.0" +description = "Python helpers for the EDC Dropmate" +authors = ["sco1 "] + +readme = "README.md" +homepage = "https://github.com/sco1/" +repository = "https://github.com/sco1/dropmate-py" +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Typing :: Typed", +] + +[tool.poetry.dependencies] +python = "^3.10" + +[tool.poetry.dev-dependencies] +black = "^23.1" +bump2version = "^1.0" +flake8 = "^6.0" +flake8-annotations = "^3.0" +flake8-bugbear = "^23.1" +flake8-docstrings = "^1.7" +flake8-fixme = "^1.1" +isort = "^5.12" +mypy = "^1.0" +pep8-naming = "^0.13" +pre-commit = "^3.0" +pytest = "^7.2" +pytest-check = "^2.1" +pytest-cov = "^4.0" +pytest-randomly = "^3.12" +tox = "^4.4" + +[tool.black] +line-length = 100 + +[tool.isort] +case_sensitive = true +known_first_party = "dropmate-py,tests" +no_lines_before = "LOCALFOLDER" +order_by_type = false +profile = "black" +line_length = 100 + +[tool.mypy] +disallow_incomplete_defs = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +ignore_missing_imports = true +no_implicit_optional = true +show_error_codes = true +warn_redundant_casts = true +warn_return_any = true +warn_unused_configs = true +warn_unused_ignores = true + +[build-system] +requires = ["poetry-core>=1.2"] +build-backend = "poetry.core.masonry.api" diff --git a/tests/test_hello.py b/tests/test_hello.py new file mode 100644 index 0000000..36a5248 --- /dev/null +++ b/tests/test_hello.py @@ -0,0 +1,2 @@ +def test_placeholder() -> None: + ... diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..7762c2a --- /dev/null +++ b/tox.ini @@ -0,0 +1,39 @@ +[pytest] +testpaths = tests/ +addopts = + --cov=dropmate-py + --cov=tests + --cov-branch + --cov-append + --cov-report term-missing:skip-covered + +[coverage:report] +exclude_lines = + pragma: no cover + if TYPE_CHECKING: + if t.TYPE_CHECKING: + if typing.TYPE_CHECKING: + +[tox] +envlist = clean,py{310,311,312} +skip_missing_interpreters = True +minversion = 3.14.0 +isolated_build = True + +[testenv] +commands = python -m pytest +deps = + pytest + pytest-check + pytest-cov + +[testenv:clean] +deps = coverage +skip_install = true +commands = coverage erase + +[gh-actions] # For tox GHA +python = + 3.10: py310 + 3.11: py311 + 3.12: py312