diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..461ca0d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,5 @@ +max_line_length = 80 + +[*.json] +indent_style = space +indent_size = 2 diff --git a/.github/actions/setup-poetry-env/action.yml b/.github/actions/setup-poetry-env/action.yml new file mode 100644 index 0000000..a7cdeb8 --- /dev/null +++ b/.github/actions/setup-poetry-env/action.yml @@ -0,0 +1,33 @@ +name: "setup-poetry-env" +description: "Composite action to setup the Python and poetry environment." + +inputs: + python-version: + required: false + description: "The python version to use" + default: "3.11" + +runs: + using: "composite" + steps: + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python-version }} + + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-in-project: true + + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v3 + with: + path: .venv + key: venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('poetry.lock') }} + + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction + shell: bash diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..55e7ff8 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,74 @@ +name: Main + +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +jobs: + quality: + runs-on: ubuntu-latest + steps: + - name: Check out + uses: actions/checkout@v3 + + - uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Set up the environment + uses: ./.github/actions/setup-poetry-env + + - name: Run checks + run: make check + + tox: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + fail-fast: false + steps: + - name: Check out + uses: actions/checkout@v3 + + - name: Set up python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Poetry + uses: snok/install-poetry@v1 + + - name: Load cached venv + uses: actions/cache@v3 + with: + path: .tox + key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }} + + - name: Install tox + run: | + python -m pip install --upgrade pip + python -m pip install tox tox-gh-actions + + - name: Test with tox + run: tox + + - name: Upload coverage reports to Codecov with GitHub Action on Python 3.11 + uses: codecov/codecov-action@v3 + if: ${{ matrix.python-version == '3.11' }} + + check-docs: + runs-on: ubuntu-latest + steps: + - name: Check out + uses: actions/checkout@v3 + + - name: Set up the environment + uses: ./.github/actions/setup-poetry-env + + - name: Check if documentation can be built + run: poetry run mkdocs build -s diff --git a/.github/workflows/on-release-main.yml b/.github/workflows/on-release-main.yml new file mode 100644 index 0000000..c2ac8b8 --- /dev/null +++ b/.github/workflows/on-release-main.yml @@ -0,0 +1,44 @@ +name: release-main + +on: + release: + types: [published] + branches: [main] + +jobs: + + publish: + runs-on: ubuntu-latest + steps: + - name: Check out + uses: actions/checkout@v3 + + - name: Set up the environment + uses: ./.github/actions/setup-poetry-env + + - name: Export tag + id: vars + run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT + + - name: Build and publish + run: | + source .venv/bin/activate + poetry version $RELEASE_VERSION + make build-and-publish + env: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + RELEASE_VERSION: ${{ steps.vars.outputs.tag }} + + deploy-docs: + needs: publish + runs-on: ubuntu-latest + steps: + - name: Check out + uses: actions/checkout@v3 + + - name: Set up the environment + uses: ./.github/actions/setup-poetry-env + + - name: Deploy documentation + run: poetry run mkdocs gh-deploy --force + diff --git a/.github/workflows/validate-codecov-config.yml b/.github/workflows/validate-codecov-config.yml new file mode 100644 index 0000000..d063161 --- /dev/null +++ b/.github/workflows/validate-codecov-config.yml @@ -0,0 +1,15 @@ +name: validate-codecov-config + +on: + pull_request: + paths: [codecov.yaml] + push: + branches: [main] + +jobs: + validate-codecov-config: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: Validate codecov configuration + run: curl -sSL --fail-with-body --data-binary @codecov.yaml https://codecov.io/validate diff --git a/.gitignore b/.gitignore index a9cfe88..9823e6a 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,171 @@ docs/_build # PyBuilder target/ .vscode + +docs/source + +# From https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore + +# 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/ + +# Vscode config files +.vscode/ + +# 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/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..5e3015b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: "v4.4.0" + hooks: + - id: check-case-conflict + - id: check-merge-conflict + - id: check-toml + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.1.6" + hooks: + - id: ruff + args: [--exit-non-zero-on-fix] + - id: ruff-format + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v3.0.3" + hooks: + - id: prettier diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ecd15b..b2554f0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,147 +1,149 @@ -Authors (chronological) -======================= +# Authors (chronological) -- [Mike Stringer](https://datascopeanalytics.com/team/mike-stringer/) -- [Vlad Seghete](https://datascopeanalytics.com/team/vlad-seghete/) -- [Yoke Peng - Leong](https://datascopeanalytics.com/team/yoke-peng-leong/) +- [Mike Stringer](https://datascopeanalytics.com/team/mike-stringer/) +- [Vlad Seghete](https://datascopeanalytics.com/team/vlad-seghete/) +- [Yoke Peng Leong](https://datascopeanalytics.com/team/yoke-peng-leong/) -Contributing -============ +# Design Philosophy -Contributions are welcome, and they are greatly appreciated! Every -little bit helps, and credit will always be given. You can contribute in -many ways. +- "Simplicity is better than functionality." - Pieter Hintjens +- "The API matters most, everything else is secondary." - Kenneth + Reitz -Design Philosophy ------------------ +# Contributing to `traces` -- "Simplicity is better than functionality." - Pieter Hintjens -- "The API matters most, everything else is secondary." - Kenneth - Reitz +Contributions are welcome, and they are greatly appreciated! +Every little bit helps, and credit will always be given. -Types of Contributions ----------------------- +You can contribute in many ways: -### Report Bugs +# Types of Contributions -Report bugs at . +## Report Bugs + +Report bugs at https://github.com/stringertheory/traces/issues If you are reporting a bug, please include: -- Your operating system name and version. -- Any details about your local setup that might be helpful - in troubleshooting. -- Detailed steps to reproduce the bug. +- Your operating system name and version. +- Any details about your local setup that might be helpful in troubleshooting. +- Detailed steps to reproduce the bug. -### Fix Bugs +## Fix Bugs -Look through the GitHub issues for bugs. Anything tagged with "bug" and -"help wanted" is open to whoever wants to implement it. +Look through the GitHub issues for bugs. Anything tagged with "bug" +and "help wanted" is open to whoever wants to implement a fix for it. -### Implement Features +## Implement Features Look through the GitHub issues for features. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it. -### Write Documentation +## Write Documentation -traces could always use more documentation, whether as part of the -official traces docs, in docstrings, or even on the web in blog posts, +Traces could always use more documentation, whether as part of the +official docs, in docstrings, or even on the web in blog posts, articles, and such. -### Submit Feedback +## Submit Feedback The best way to send feedback is to file an issue at -. +https://github.com/stringertheory/traces/issues. + +If you are proposing a new feature: + +- Explain in detail how it would work. +- Keep the scope as narrow as possible, to make it easier to implement. +- Remember that this is a volunteer-driven project, and that contributions + are welcome :) + +# Get Started! + +Ready to contribute? Here's how to set up `traces` for local development. +Please note this documentation assumes you already have `poetry` and `Git` installed and ready to go. -If you are proposing a feature: +1. Fork the `traces` repo on GitHub. -- Explain in detail how it would work. -- Keep the scope as narrow as possible, to make it easier - to implement. -- Remember that this is a volunteer-driven project, and that - contributions are welcome :) +2. Clone your fork locally: -When you are suggesting an enhancement, please include specific use -cases that demonstrate why the proposed enhancement is useful and make -sure that the proposed enhancement is aligned with the goals of the -project. +```bash +cd +git clone git@github.com:YOUR_NAME/traces.git +``` -Get Started! ------------- +3. Now we need to install the environment. Navigate into the directory -Ready to contribute? Here's how to set up `traces` for local -development. +```bash +cd traces +``` -1. Fork the `traces` repo on GitHub. -2. Clone your fork locally: +If you are using `pyenv`, select a version to use locally. (See installed versions with `pyenv versions`) - ``` {.sourceCode .bash} - $ git clone git@github.com:your_name_here/traces.git - ``` +```bash +pyenv local +``` -3. Install your local copy into a virtualenv. Assuming you have - virtualenvwrapper installed, this is how you set up your fork for - local development: +Then, install and activate the environment with: - ``` {.sourceCode .bash} - $ mkvirtualenv traces - $ cd traces/ - $ python setup.py develop - ``` +```bash +poetry install +poetry shell +``` -4. Create a branch for local development: +4. Install pre-commit to run linters/formatters at commit time: - ``` {.sourceCode .bash} - $ git checkout -b name-of-your-bugfix-or-feature - ``` +```bash +poetry run pre-commit install +``` + +5. Create a branch for local development: + +```bash +git checkout -b name-of-your-bugfix-or-feature +``` Now you can make your changes locally. -5. When you're done making changes, check that your changes pass flake8 - and the tests, including testing other Python versions with tox: +6. Don't forget to add test cases for your added functionality to the `tests` directory. - .. code:: bash +7. When you're done making changes, check that your changes pass the formatting tests. - > \$ flake8 traces tests \$ python setup.py test or py.test \$ tox +```bash +make check +``` -To get flake8 and tox, just pip install them into your virtualenv. +Now, validate that all unit tests are passing: -6. Commit your changes and push your branch to GitHub: +```bash +make test +``` - ``` {.sourceCode .bash} - $ git add . - $ git commit -m "Your detailed description of your changes." - $ git push origin name-of-your-bugfix-or-feature - ``` +9. Before raising a pull request you should also run tox. + This will run the tests across different versions of Python: -7. Submit a pull request through the GitHub website. +```bash +tox +``` -Pull Request Guidelines ------------------------ +This requires you to have multiple versions of python installed. +This step is also triggered in the CI/CD pipeline, so you could also choose to skip this step locally. -Pull requests are welcome! If the pull request is in response to an -existing Bug Report or Enhancement Request, please refer to it in the -description. Otherwise, if the pull request is a bug fix then make sure -to describe the bug just like if it were a bug report issue. If it's an -enhancement, describe the uses cases like you would when creating an -enhancement request. +10. Commit your changes and push your branch to GitHub: -Before you submit a pull request, check that it meets these guidelines: +```bash +git add . +git commit -m "Your detailed description of your changes." +git push origin name-of-your-bugfix-or-feature +``` -1. The pull request should include tests. -2. If the pull request adds functionality, the docs should be updated. - Put your new functionality into a function with a docstring, and add - the feature to the list in README.rst. -3. The pull request should work for Python 3.5-3.8. Check - and make sure - that the tests pass for all supported Python versions. +11. Submit a pull request through the GitHub website. -Tips ----- +# Pull Request Guidelines + +Before you submit a pull request, check that it meets these guidelines: -To run a subset of tests: +1. The pull request should include tests. - $ python -m unittest tests.test_traces +2. If the pull request adds functionality, the docs should be updated. + Put your new functionality into a function with a docstring, and add the feature to the list in `README.md`. diff --git a/Makefile b/Makefile index 798eec2..2a01119 100644 --- a/Makefile +++ b/Makefile @@ -1,82 +1,54 @@ -.PHONY: clean clean-test clean-pyc clean-build docs help -.DEFAULT_GOAL := help -define BROWSER_PYSCRIPT -import os, webbrowser, sys -try: - from urllib import pathname2url -except: - from urllib.request import pathname2url - -webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1]))) -endef -export BROWSER_PYSCRIPT - -define PRINT_HELP_PYSCRIPT -import re, sys - -for line in sys.stdin: - match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) - if match: - target, help = match.groups() - print("%-20s %s" % (target, help)) -endef -export PRINT_HELP_PYSCRIPT -BROWSER := python -c "$$BROWSER_PYSCRIPT" - +.PHONY: install +install: ## Install the poetry environment and install the pre-commit hooks + @echo "🚀 Creating virtual environment using pyenv and poetry" + @poetry install + @ poetry run pre-commit install + @poetry shell + +.PHONY: check +check: ## Run code quality tools. + @echo "🚀 Checking Poetry lock file consistency with 'pyproject.toml': Running poetry lock --check" + @poetry check --lock + @echo "🚀 Linting code: Running pre-commit" + @poetry run pre-commit run -a + @echo "🚀 Static type checking: Running mypy" + @poetry run mypy + +.PHONY: test +test: ## Test the code with pytest + @echo "🚀 Testing code: Running pytest" + @poetry run pytest --cov --cov-config=pyproject.toml --cov-report=xml + +.PHONY: build +build: clean-build ## Build wheel file using poetry + @echo "🚀 Creating wheel file" + @poetry build + +.PHONY: clean-build +clean-build: ## clean build artifacts + @rm -rf dist + +.PHONY: publish +publish: ## publish a release to pypi. + @echo "🚀 Publishing: Dry run." + @poetry config pypi-token.pypi $(PYPI_TOKEN) + @poetry publish --dry-run + @echo "🚀 Publishing." + @poetry publish + +.PHONY: build-and-publish +build-and-publish: build publish ## Build and publish. + +.PHONY: docs-test +docs-test: ## Test if documentation can be built without warnings or errors + @poetry run mkdocs build -s + +.PHONY: docs +docs: ## Build and serve the documentation + @poetry run mkdocs serve + +.PHONY: help help: - @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) - -clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts - - -clean-build: ## remove build artifacts - rm -fr build/ - rm -fr dist/ - rm -fr .eggs/ - find . -name '*.egg-info' -exec rm -fr {} + - find . -name '*.egg' -exec rm -f {} + - -clean-pyc: ## remove Python file artifacts - find . -name '*.pyc' -exec rm -f {} + - find . -name '*.pyo' -exec rm -f {} + - find . -name '*~' -exec rm -f {} + - find . -name '__pycache__' -exec rm -fr {} + - -clean-test: ## remove test and coverage artifacts - rm -fr .tox/ - rm -f .coverage - rm -fr htmlcov/ + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' -lint: ## check style with flake8 - flake8 traces tests - -test: ## run tests quickly with the default Python - nosetests --with-coverage --cover-package=traces - pycodestyle traces - pytest --mpl tests/test_plot.py - -test-all: ## run tests on every Python version with tox - tox - -coverage: ## check code coverage quickly with the default Python - coverage run --source traces setup.py test - coverage report -m - coverage html - $(BROWSER) htmlcov/index.html - -docs: ## generate HTML documentation - cd docs && make html - -servedocs: ## compile the docs watching for changes - sphinx-autobuild -z traces/ docs docs/_build/html - -release: clean ## package and upload a release - python setup.py sdist bdist_wheel - twine upload dist/* - -dist: clean ## builds source and wheel package - python setup.py sdist bdist_wheel - ls -l dist - -install: clean ## install the package to the active Python's site-packages - python setup.py install +.DEFAULT_GOAL := help diff --git a/codecov.yaml b/codecov.yaml new file mode 100644 index 0000000..058cfb7 --- /dev/null +++ b/codecov.yaml @@ -0,0 +1,9 @@ +coverage: + range: 70..100 + round: down + precision: 1 + status: + project: + default: + target: 90% + threshold: 0.5% diff --git a/mkdocs.yml b/mkdocs.yml index 5ffc839..2516c95 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,15 +1,54 @@ site_name: traces -repo_url: https://github.com/datascopeanalytics/traces/tree/master -theme: readthedocs -site_description: Tools for unevenly-spaced time series data +repo_url: https://github.com/stringertheory/traces +site_url: https://stringertheory.github.io/traces +site_description: A Python library for unevenly-spaced time series analysis site_author: Mike Stringer -site_favicon: http://datascopeanalytics.com/static/main/img/favicon.ico -copyright: -extra_javascript: - - http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML +edit_uri: edit/main/docs/ +repo_name: stringertheory/traces +copyright: Maintained by Mike. + +nav: + - Home: index.md + - Modules: modules.md +plugins: + - search + - mkdocstrings: + handlers: + python: + setup_commands: + - import sys + - sys.path.append('../') +theme: + name: material + feature: + tabs: true + palette: + - media: "(prefers-color-scheme: light)" + scheme: default + primary: white + accent: deep orange + toggle: + icon: material/brightness-7 + name: Switch to dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + primary: black + accent: deep orange + toggle: + icon: material/brightness-4 + name: Switch to light mode + icon: + repo: fontawesome/brands/github + +extra: + social: + - icon: fontawesome/brands/github + link: https://github.com/stringertheory/traces + - icon: fontawesome/brands/python + link: https://pypi.org/project/traces + markdown_extensions: - - smarty - - mdx_math -pages: -- Home: 'index.md' -- Installation: 'installation.md' + - toc: + permalink: true + - pymdownx.arithmatex: + generic: true diff --git a/poetry.toml b/poetry.toml new file mode 100644 index 0000000..ab1033b --- /dev/null +++ b/poetry.toml @@ -0,0 +1,2 @@ +[virtualenvs] +in-project = true diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..bc4dabb --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,100 @@ +[tool.poetry] +name = "traces" +version = "0.0.1" +description = "A Python library for unevenly-spaced time series analysis" +authors = ["Mike Stringer "] +repository = "https://github.com/stringertheory/traces" +documentation = "https://stringertheory.github.io/traces/" +readme = "README.md" +packages = [ + {include = "traces"} +] + +[tool.poetry.dependencies] +python = ">=3.8,<4.0" + +[tool.poetry.group.dev.dependencies] +pytest = "^7.2.0" +pytest-cov = "^4.0.0" +mypy = "^1.5.1" +pre-commit = "^3.4.0" +tox = "^4.11.1" + +[tool.poetry.group.docs.dependencies] +mkdocs = "^1.4.2" +mkdocs-material = "^9.2.7" +mkdocstrings = {extras = ["python"], version = "^0.23.0"} + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" + +[tool.mypy] +files = ["traces"] +disallow_untyped_defs = "True" +disallow_any_unimported = "True" +no_implicit_optional = "True" +check_untyped_defs = "True" +warn_return_any = "True" +warn_unused_ignores = "True" +show_error_codes = "True" + +[tool.pytest.ini_options] +testpaths = ["tests"] + +[tool.ruff] +target-version = "py37" +line-length = 120 +fix = true +select = [ + # flake8-2020 + "YTT", + # flake8-bandit + "S", + # flake8-bugbear + "B", + # flake8-builtins + "A", + # flake8-comprehensions + "C4", + # flake8-debugger + "T10", + # flake8-simplify + "SIM", + # isort + "I", + # mccabe + "C90", + # pycodestyle + "E", "W", + # pyflakes + "F", + # pygrep-hooks + "PGH", + # pyupgrade + "UP", + # ruff + "RUF", + # tryceratops + "TRY", +] +ignore = [ + # LineTooLong + "E501", + # DoNotAssignLambda + "E731", +] + +[tool.ruff.format] +preview = true + +[tool.coverage.report] +skip_empty = true + +[tool.coverage.run] +branch = true +source = ["traces"] + + +[tool.ruff.per-file-ignores] +"tests/*" = ["S101"] diff --git a/tox.ini b/tox.ini index 5630c12..0ab4522 100644 --- a/tox.ini +++ b/tox.ini @@ -1,20 +1,21 @@ [tox] -envlist = py36, py37, py38, pycodestyle skipsdist = true +envlist = py36, py37, py38, py39, py310, py311, py312 -[testenv:pycodestyle] -basepython=python -deps=pycodestyle -commands=pycodestyle traces +[gh-actions] +python = + 3.6: py36 + 3.7: py37 + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 + 3.12: py312 [testenv] -setenv = - PYTHONPATH = {toxinidir}:{toxinidir}/traces -deps = - -r{toxinidir}/requirements/python-test.txt -commands = python setup.py test - -; If you want to make tox run the tests with the same versions, create a -; requirements.txt with the pinned versions and uncomment the following lines: -; deps = -; -r{toxinidir}/requirements.txt +passenv = PYTHON_VERSION +allowlist_externals = poetry +commands = + poetry install -v + pytest --doctest-modules tests --cov --cov-config=pyproject.toml --cov-report=xml + mypy