diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 8f6d25b..a70f143 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -1,11 +1,9 @@
----
+______________________________________________________________________
-name: Bug Report
-about: Create a bug report to help us improve pytask-environment
-title: "BUG:"
-labels: "bug"
+name: Bug Report about: Create a bug report to help us improve pytask-environment title:
+"BUG:" labels: "bug"
----
+______________________________________________________________________
- [ ] I have checked that this issue has not already been reported.
@@ -14,11 +12,11 @@ labels: "bug"
- [ ] (optional) I have confirmed this bug exists on the `main` branch of
pytask-environment.
----
+______________________________________________________________________
-**Note**: Please read [this
-guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) detailing
-how to provide the necessary information for us to reproduce your bug.
+**Note**: Please read
+[this guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports)
+detailing how to provide the necessary information for us to reproduce your bug.
#### Code Sample, a copy-pastable example
diff --git a/.github/ISSUE_TEMPLATE/documentation.md b/.github/ISSUE_TEMPLATE/documentation.md
index 7019681..ced6381 100644
--- a/.github/ISSUE_TEMPLATE/documentation.md
+++ b/.github/ISSUE_TEMPLATE/documentation.md
@@ -1,11 +1,9 @@
----
+______________________________________________________________________
-name: Documentation Improvement
-about: Report wrong or missing documentation
-title: "DOC:"
-labels: "documentation"
+name: Documentation Improvement about: Report wrong or missing documentation title:
+"DOC:" labels: "documentation"
----
+______________________________________________________________________
#### Location of the documentation
diff --git a/.github/ISSUE_TEMPLATE/enhancement.md b/.github/ISSUE_TEMPLATE/enhancement.md
index 67f20d4..252db46 100644
--- a/.github/ISSUE_TEMPLATE/enhancement.md
+++ b/.github/ISSUE_TEMPLATE/enhancement.md
@@ -1,16 +1,14 @@
----
+______________________________________________________________________
-name: Enhancement
-about: Suggest an idea for pytask-environment
-title: "ENH:"
-labels: "enhancement"
+name: Enhancement about: Suggest an idea for pytask-environment title: "ENH:" labels:
+"enhancement"
----
+______________________________________________________________________
#### Is your feature request related to a problem?
-Provide a description of what the problem is, e.g. "I wish I could use pytask-environment
-to do [...]".
+Provide a description of what the problem is, e.g. "I wish I could use
+pytask-environment to do \[...\]".
#### Describe the solution you'd like
diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md
index 2052eee..f5d97c3 100644
--- a/.github/ISSUE_TEMPLATE/question.md
+++ b/.github/ISSUE_TEMPLATE/question.md
@@ -1,17 +1,15 @@
----
+______________________________________________________________________
-name: Submit Question
-about: Ask a general question about pytask-environment
-title: "QST:"
-labels: "question"
+name: Submit Question about: Ask a general question about pytask-environment title:
+"QST:" labels: "question"
----
+______________________________________________________________________
#### Question about pytask-environment
-**Note**: If you'd still like to submit a question, please read [this guide](
-https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) detailing how to
-provide the necessary information for us to reproduce your question.
+**Note**: If you'd still like to submit a question, please read
+[this guide](https://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports)
+detailing how to provide the necessary information for us to reproduce your question.
```python
# Your code here, if applicable
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 1817a2f..b627f37 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -6,4 +6,4 @@ Provide a description and/or bullet points to describe the changes in this PR.
- [ ] Reference issues which can be closed due to this PR with "Closes #x".
- [ ] Review whether the documentation needs to be updated.
-- [ ] Document PR in docs/changes.rst.
+- [ ] Document PR in CHANGES.md.
diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/main.yml
similarity index 91%
rename from .github/workflows/continuous-integration-workflow.yml
rename to .github/workflows/main.yml
index 60a90e2..e6b29ef 100644
--- a/.github/workflows/continuous-integration-workflow.yml
+++ b/.github/workflows/main.yml
@@ -1,4 +1,5 @@
-name: Continuous Integration Workflow
+name: main
+
on:
push:
branches:
@@ -38,7 +39,7 @@ jobs:
- name: Run end-to-end tests.
shell: bash -l {0}
- run: tox -e pytest -- -m end_to_end --cov=./ --cov-report=xml
+ run: tox -e pytest -- tests -m end_to_end --cov=./ --cov-report=xml
- name: Upload coverage reports of end-to-end tests.
if: runner.os == 'Linux' && matrix.python-version == '3.9'
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 7908dc5..6b5ed6c 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -24,9 +24,6 @@ repos:
- id: python-no-eval
- id: python-no-log-warn
- id: python-use-type-annotations
- - id: rst-backticks
- - id: rst-directive-colons
- - id: rst-inline-touching-normal
- id: text-unicode-replacement-char
- repo: https://github.com/asottile/pyupgrade
rev: v2.32.0
@@ -42,11 +39,6 @@ repos:
rev: 22.3.0
hooks:
- id: black
-- repo: https://github.com/asottile/blacken-docs
- rev: v1.12.1
- hooks:
- - id: blacken-docs
- additional_dependencies: [black]
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
@@ -68,10 +60,6 @@ repos:
pydocstyle,
Pygments,
]
-- repo: https://github.com/PyCQA/doc8
- rev: 0.11.1
- hooks:
- - id: doc8
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.20.1
hooks:
@@ -81,6 +69,15 @@ repos:
hooks:
- id: interrogate
args: [-v, --fail-under=40, src, tests]
+- repo: https://github.com/executablebooks/mdformat
+ rev: 0.7.14
+ hooks:
+ - id: mdformat
+ additional_dependencies: [
+ mdformat-gfm,
+ mdformat-black,
+ ]
+ args: [--wrap, "88"]
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
@@ -90,6 +87,8 @@ repos:
rev: "0.48"
hooks:
- id: check-manifest
+ args: [--no-build-isolation]
+ additional_dependencies: [setuptools-scm, toml]
- repo: meta
hooks:
- id: check-hooks-apply
diff --git a/CHANGES.md b/CHANGES.md
new file mode 100644
index 0000000..02ccda0
--- /dev/null
+++ b/CHANGES.md
@@ -0,0 +1,44 @@
+# Changes
+
+This is a record of all past pytask-environment releases and what went into them in
+reverse chronological order. Releases follow [semantic versioning](https://semver.org/)
+and all releases are available on
+[Anaconda.org](https://anaconda.org/conda-forge/pytask-environment).
+
+## 0.2.0 - 2022-16-04
+
+- {pull}`15` aligns pytask-environment with pytask v0.2.0.
+
+## 0.1.1 - 2022-02-08
+
+- {pull}`13` deprecates Python 3.6 and adds support for Python 3.10.
+
+## 0.1.0 - 2022-01-25
+
+- {pull}`10` replaces the input prompts with configuration values and flags, removes the
+ conda recipe, and abort simultaneously running builds.
+
+## 0.0.6 - 2021-07-23
+
+- {pull}`8` replaces versioneer with setuptools-scm.
+
+## 0.0.5 - 2021-07-23
+
+- {pull}`7` adds some pre-commit updates.
+
+## 0.0.4 - 2021-03-05
+
+- {pull}`6` fixes the version number which is displayed during execution.
+
+## 0.0.3 - 2021-03-03
+
+- {pull}`5` adds dependencies to `setup.py` and missing `README.rst` to package.
+
+## 0.0.2 - 2021-02-27
+
+- {pull}`3` prepares pytask-environment to be published on PyPI, adds versioneer, and
+ more.
+
+## 0.0.1 - 2020-10-04
+
+- Release v0.0.1.
diff --git a/CHANGES.rst b/CHANGES.rst
deleted file mode 100644
index 484ff0e..0000000
--- a/CHANGES.rst
+++ /dev/null
@@ -1,57 +0,0 @@
-Changes
-=======
-
-This is a record of all past pytask-environment releases and what went into them in
-reverse chronological order. Releases follow `semantic versioning
-`_ and all releases are available on `Anaconda.org
-`_.
-
-
-0.1.1 - 2022-02-08
-------------------
-
-- :gh:`13` deprecates Python 3.6 and adds support for Python 3.10.
-
-
-0.1.0 - 2022-01-25
-------------------
-
-- :gh:`10` replaces the input prompts with configuration values and flags, removes the
- conda recipe, and abort simultaneously running builds.
-
-
-0.0.6 - 2021-07-23
-------------------
-
-- :gh:`8` replaces versioneer with setuptools-scm.
-
-
-0.0.5 - 2021-07-23
-------------------
-
-- :gh:`7` adds some pre-commit updates.
-
-
-0.0.4 - 2021-03-05
-------------------
-
-- :gh:`6` fixes the version number which is displayed during execution.
-
-
-0.0.3 - 2021-03-03
-------------------
-
-- :gh:`5` adds dependencies to ``setup.py`` and missing ``README.rst`` to package.
-
-
-0.0.2 - 2021-02-27
-------------------
-
-- :gh:`3` prepares pytask-environment to be published on PyPI, adds versioneer, and
- more.
-
-
-0.0.1 - 2020-10-04
-------------------
-
-- Release v0.0.1.
diff --git a/LICENSE b/LICENSE
index 4c96cf3..f4c44ec 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright 2020-2021 Tobias Raabe
+Copyright 2020 Tobias Raabe
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
diff --git a/MANIFEST.in b/MANIFEST.in
index f450948..61f5ebe 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,11 +1,11 @@
prune tests
-exclude *.rst
+exclude *.md
exclude *.yml
exclude *.yaml
exclude tox.ini
-include README.rst
+include README.md
include LICENSE
recursive-include _static *.png
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..30b733c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,65 @@
+# pytask-environment
+
+[](https://pypi.org/project/pytask-environment)
+[](https://pypi.org/project/pytask-environment)
+[](https://anaconda.org/conda-forge/pytask-environment)
+[](https://anaconda.org/conda-forge/pytask-environment)
+[](https://pypi.org/project/pytask-environment)
+[](https://github.com/pytask-dev/pytask-environment/actions?query=branch%3Amain)
+[](https://codecov.io/gh/pytask-dev/pytask-environment)
+[](https://results.pre-commit.ci/latest/github/pytask-dev/pytask-environment/main)
+[](https://github.com/psf/black)
+
+______________________________________________________________________
+
+pytask-environment allows you to detect changes in your pytask environment and abort a
+project build.
+
+## Installation
+
+pytask-environment is available on [PyPI](https://pypi.org/project/pytask-environment)
+and [Anaconda.org](https://anaconda.org/conda-forge/pytask-environment). Install it with
+
+```console
+$ pip install pytask-environment
+
+# or
+
+$ conda install -c conda-forge pytask-environment
+```
+
+## Usage
+
+If the user attempts to build the project with `pytask build` and the Python version has
+been cached in the database in a previous run, an invocation with a different
+environment will produce the following command line output.
+
+
+
+Running
+
+```console
+$ pytask --update-environment
+```
+
+will update the information on the environment.
+
+To disable either checking the path or the version, set the following configuration to a
+falsy value.
+
+```toml
+[tool.pytask.ini_options]
+check_python_version = false # true by default
+
+check_environment = false # true by default
+```
+
+## Future development
+
+The plugin might be further extended to compare the current environment against an
+`environment.yml` or a list of packages and versions to ensure that the environment is
+not altered.
+
+## Changes
+
+Consult the [release notes](CHANGES.md) to find out about what is new.
diff --git a/README.rst b/README.rst
deleted file mode 100644
index 6a599ce..0000000
--- a/README.rst
+++ /dev/null
@@ -1,97 +0,0 @@
-.. image:: https://img.shields.io/pypi/v/pytask-environment?color=blue
- :alt: PyPI
- :target: https://pypi.org/project/pytask-environment
-
-.. image:: https://img.shields.io/pypi/pyversions/pytask-environment
- :alt: PyPI - Python Version
- :target: https://pypi.org/project/pytask-environment
-
-.. image:: https://img.shields.io/conda/vn/conda-forge/pytask-environment.svg
- :target: https://anaconda.org/conda-forge/pytask-environment
-
-.. image:: https://img.shields.io/conda/pn/conda-forge/pytask-environment.svg
- :target: https://anaconda.org/conda-forge/pytask-environment
-
-.. image:: https://img.shields.io/pypi/l/pytask-environment
- :alt: PyPI - License
- :target: https://pypi.org/project/pytask-environment
-
-.. image:: https://img.shields.io/github/workflow/status/pytask-dev/pytask-environment/Continuous%20Integration%20Workflow/main
- :target: https://github.com/pytask-dev/pytask-environment/actions?query=branch%3Amain
-
-.. image:: https://codecov.io/gh/pytask-dev/pytask-environment/branch/main/graph/badge.svg
- :target: https://codecov.io/gh/pytask-dev/pytask-environment
-
-.. image:: https://results.pre-commit.ci/badge/github/pytask-dev/pytask-environment/main.svg
- :target: https://results.pre-commit.ci/latest/github/pytask-dev/pytask-environment/main
- :alt: pre-commit.ci status
-
-.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
- :target: https://github.com/psf/black
-
-------
-
-pytask-environment
-==================
-
-pytask-environment allows you to detect changes in your pytask environment and abort a
-project build.
-
-
-Installation
-------------
-
-pytask-environment is available on `PyPI `_
-and `Anaconda.org `_. Install it
-with
-
-.. code-block:: console
-
- $ pip install pytask-environment
-
- # or
-
- $ conda install -c conda-forge pytask-environment
-
-
-Usage
------
-
-If the user attempts to build the project with ``pytask build`` and the Python version
-has been cached in the database in a previous run, an invocation with a different
-environment will produce the following command line output.
-
-.. image:: _static/error.png
-
-Running
-
-.. code-block:: console
-
- $ pytask --update-environment
-
-will update the information on the environment.
-
-To disable either checking the path or the version, set the following configuration to a
-falsy value.
-
-.. code-block:: ini
-
- # Content of pytask.ini, setup.cfg, or tox.ini
-
- check_python_version = false # true by default
-
- check_environment = false # true by default
-
-
-Future development
-------------------
-
-The plugin might be further extended to compare the current environment against an
-``environment.yml`` or a list of packages and versions to ensure that the environment is
-not altered.
-
-
-Changes
--------
-
-Consult the `release notes `_ to find out about what is new.
diff --git a/environment.yml b/environment.yml
index 6d13e82..e87d693 100644
--- a/environment.yml
+++ b/environment.yml
@@ -10,17 +10,10 @@ dependencies:
- setuptools_scm
- toml
- # Conda
- - anaconda-client
- - conda-build
- - conda-verify
-
# Package dependencies
- - pytask >= 0.0.7
+ - pytask >=0.2
# Misc
- - bumpversion
- - jupyterlab
- - pdbpp
- pre-commit
+ - pytest
- pytest-cov
diff --git a/pyproject.toml b/pyproject.toml
index 6e40e05..51b714f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,6 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
+build-backend = "setuptools.build_meta"
[tool.setuptools_scm]
diff --git a/setup.cfg b/setup.cfg
index 0f11477..b576a98 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,8 +1,8 @@
[metadata]
name = pytask_environment
description = Detect changes in your pytask environment and abort a project build.
-long_description = file: README.rst
-long_description_content_type = text/x-rst
+long_description = file: README.md
+long_description_content_type = text/markdown
url = https://github.com/pytask-dev/pytask-environment
author = Tobias Raabe
author_email = raabe@posteo.de
@@ -10,7 +10,7 @@ license = MIT
license_file = LICENSE
platforms = any
classifiers =
- Development Status :: 3 - Alpha
+ Development Status :: 4 - Beta
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 3
@@ -20,7 +20,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
project_urls =
- Changelog = https://github.com/pytask-dev/pytask-environment/blob/main/CHANGES.rst
+ Changelog = https://github.com/pytask-dev/pytask-environment/blob/main/CHANGES.md
Documentation = https://github.com/pytask-dev/pytask-environment
Github = https://github.com/pytask-dev/pytask-environment
Tracker = https://github.com/pytask-dev/pytask-environment/issues
@@ -30,7 +30,7 @@ packages = find:
install_requires =
click
pony
- pytask>=0.1.7
+ pytask>=0.2
python_requires = >=3.7
include_package_data = True
package_dir = =src
diff --git a/setup.py b/setup.py
deleted file mode 100644
index c21a9ee..0000000
--- a/setup.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from __future__ import annotations
-
-from setuptools import setup
-
-
-if __name__ == "__main__":
- setup()
diff --git a/src/pytask_environment/__init__.py b/src/pytask_environment/__init__.py
index f493641..dcc8e73 100644
--- a/src/pytask_environment/__init__.py
+++ b/src/pytask_environment/__init__.py
@@ -2,7 +2,7 @@
try:
from ._version import version as __version__
-except ImportError:
+except ImportError: # pragma: no cover
# broken installation, we don't even try unknown only works because we do poor mans
# version compare
__version__ = "unknown"
diff --git a/src/pytask_environment/config.py b/src/pytask_environment/config.py
index 70fa747..20f1ffe 100644
--- a/src/pytask_environment/config.py
+++ b/src/pytask_environment/config.py
@@ -1,13 +1,14 @@
from __future__ import annotations
+from typing import Any
+from typing import Callable
+
import click
-from _pytask.config import hookimpl
-from _pytask.shared import convert_truthy_or_falsy_to_bool
-from _pytask.shared import get_first_non_none_value
+from pytask import hookimpl
@hookimpl
-def pytask_extend_command_line_interface(cli):
+def pytask_extend_command_line_interface(cli: click.Group) -> None:
"""Extend the cli."""
cli.commands["build"].params.append(
click.Option(
@@ -20,25 +21,61 @@ def pytask_extend_command_line_interface(cli):
@hookimpl
-def pytask_parse_config(config, config_from_file, config_from_cli):
+def pytask_parse_config(
+ config: dict[str, Any],
+ config_from_file: dict[str, Any],
+ config_from_cli: dict[str, Any],
+) -> None:
"""Parse the configuration."""
- config["check_python_version"] = get_first_non_none_value(
+ config["check_python_version"] = _get_first_non_none_value(
config_from_file,
key="check_python_version",
default=True,
- callback=convert_truthy_or_falsy_to_bool,
+ callback=_convert_truthy_or_falsy_to_bool,
)
- config["check_environment"] = get_first_non_none_value(
+ config["check_environment"] = _get_first_non_none_value(
config_from_file,
key="check_environment",
default=True,
- callback=convert_truthy_or_falsy_to_bool,
+ callback=_convert_truthy_or_falsy_to_bool,
)
- config["update_environment"] = get_first_non_none_value(
+ config["update_environment"] = _get_first_non_none_value(
config_from_cli,
key="update_environment",
default=False,
- callback=convert_truthy_or_falsy_to_bool,
+ callback=_convert_truthy_or_falsy_to_bool,
)
+
+
+def _get_first_non_none_value(
+ *configs: dict[str, Any],
+ key: str,
+ default: Any | None = None,
+ callback: Callable[..., Any] | None = None,
+) -> Any:
+ """Get the first non-None value for a key from a list of dictionaries.
+
+ This function allows to prioritize information from many configurations by changing
+ the order of the inputs while also providing a default.
+
+ """
+ callback = (lambda x: x) if callback is None else callback # noqa: E731
+ processed_values = (callback(config.get(key)) for config in configs)
+ return next((value for value in processed_values if value is not None), default)
+
+
+def _convert_truthy_or_falsy_to_bool(x: bool | str | None) -> bool:
+ """Convert truthy or falsy value in .ini to Python boolean."""
+ if x in [True, "True", "true", "1"]:
+ out = True
+ elif x in [False, "False", "false", "0"]:
+ out = False
+ elif x in [None, "None", "none"]:
+ out = None
+ else:
+ raise ValueError(
+ f"Input {x!r} is neither truthy (True, true, 1) or falsy (False, false, 0)."
+ )
+ return out
diff --git a/src/pytask_environment/database.py b/src/pytask_environment/database.py
index cc0c1a4..a70b3df 100644
--- a/src/pytask_environment/database.py
+++ b/src/pytask_environment/database.py
@@ -1,7 +1,7 @@
from __future__ import annotations
-from _pytask.database import db
from pony import orm
+from pytask import db
class Environment(db.Entity):
diff --git a/src/pytask_environment/logging.py b/src/pytask_environment/logging.py
index 7076839..6c2ead0 100644
--- a/src/pytask_environment/logging.py
+++ b/src/pytask_environment/logging.py
@@ -2,9 +2,10 @@
import sys
-from _pytask.config import hookimpl
-from _pytask.console import console
from pony import orm
+from pytask import console
+from pytask import hookimpl
+from pytask import Session
from pytask_environment.database import Environment
@@ -16,7 +17,7 @@
@hookimpl(trylast=True)
-def pytask_log_session_header(session) -> None:
+def pytask_log_session_header(session: Session) -> None:
"""Check environment and python version.
The solution is hacky. Exploit the first entry-point in the build process after the
@@ -70,7 +71,7 @@ def pytask_log_session_header(session) -> None:
@orm.db_session
-def retrieve_package(name):
+def retrieve_package(name: str) -> str:
"""Return booleans indicating whether the version or path of a package changed."""
try:
package = Environment[name]
@@ -80,7 +81,7 @@ def retrieve_package(name):
@orm.db_session
-def create_or_update_state(name, version, path):
+def create_or_update_state(name: str, version: str, path: str) -> None:
"""Create or update a state."""
try:
package_in_db = Environment[name]
diff --git a/src/pytask_environment/plugin.py b/src/pytask_environment/plugin.py
index 3ab9081..fe15957 100644
--- a/src/pytask_environment/plugin.py
+++ b/src/pytask_environment/plugin.py
@@ -1,7 +1,7 @@
"""Entry-point for the plugin."""
from __future__ import annotations
-from _pytask.config import hookimpl
+from pytask import hookimpl
from pytask_environment import config
from pytask_environment import database
from pytask_environment import logging
diff --git a/tests/test_logging.py b/tests/test_logging.py
index 913412f..a65afd4 100644
--- a/tests/test_logging.py
+++ b/tests/test_logging.py
@@ -4,9 +4,10 @@
import textwrap
import pytest
-from _pytask.database import db
from pony import orm
from pytask import cli
+from pytask import db
+from pytask import ExitCode
from pytask_environment.database import Environment
@@ -19,7 +20,7 @@ def test_existence_of_python_executable_in_db(tmp_path, runner):
result = runner.invoke(cli, [tmp_path.as_posix()])
- assert result.exit_code == 0
+ assert result.exit_code == ExitCode.OK
with orm.db_session:
python = Environment["python"]
@@ -32,12 +33,14 @@ def test_existence_of_python_executable_in_db(tmp_path, runner):
orm.delete(e for e in entity)
-@pytest.mark.skipif(
- sys.platform == "win32" and sys.version_info[:2] == (3, 6),
- reason="Error on Windows with Python 3.6",
-)
@pytest.mark.end_to_end
-def test_flow_when_python_version_has_changed(monkeypatch, tmp_path, runner):
+@pytest.mark.parametrize(
+ "config_file, content",
+ [("pytask.ini", "[pytask]"), ("pyproject.toml", "[tool.pytask.ini_options]")],
+)
+def test_flow_when_python_version_has_changed(
+ monkeypatch, tmp_path, runner, config_file, content
+):
"""Test the whole use-case.
1. Run a simple task to cache the Python version and path.
@@ -54,21 +57,21 @@ def test_flow_when_python_version_has_changed(monkeypatch, tmp_path, runner):
"[MSC v.1916 64 bit (AMD64)]"
)
- tmp_path.joinpath("pytask.ini").write_text("[pytask]")
+ tmp_path.joinpath(config_file).write_text(content)
source = "def task_dummy(): pass"
task_path = tmp_path.joinpath("task_dummy.py")
task_path.write_text(textwrap.dedent(source))
# Run without knowing the python version and without updating the environment.
result = runner.invoke(cli, [tmp_path.as_posix()])
- assert result.exit_code == 0
+ assert result.exit_code == ExitCode.OK
assert "Updating the information" in result.output
# Run with a fake version and not updating the environment.
monkeypatch.setattr("pytask_environment.logging.sys.version", fake_version)
result = runner.invoke(cli)
- assert result.exit_code == 1
+ assert result.exit_code == ExitCode.FAILED
with orm.db_session:
python = Environment["python"]
@@ -80,8 +83,8 @@ def test_flow_when_python_version_has_changed(monkeypatch, tmp_path, runner):
monkeypatch.setattr("pytask_environment.logging.sys.version", fake_version)
monkeypatch.setattr("pytask_environment.logging.sys.executable", "new_path")
- result = runner.invoke(cli, ["--update-environment"])
- assert result.exit_code == 0
+ result = runner.invoke(cli, ["--update-environment", tmp_path.as_posix()])
+ assert result.exit_code == ExitCode.OK
with orm.db_session:
python = Environment["python"]
@@ -95,24 +98,29 @@ def test_flow_when_python_version_has_changed(monkeypatch, tmp_path, runner):
@pytest.mark.end_to_end
+@pytest.mark.parametrize(
+ "config_file, content",
+ [
+ ("pytask.ini", "[pytask]\ncheck_python_version = {}"),
+ ("pyproject.toml", "[tool.pytask.ini_options]\ncheck_python_version = {}"),
+ ],
+)
@pytest.mark.parametrize("check_python_version, expected", [("true", 1), ("false", 0)])
def test_python_version_changed(
- monkeypatch, tmp_path, runner, check_python_version, expected
+ monkeypatch, tmp_path, runner, config_file, content, check_python_version, expected
):
fake_version = (
"2.7.8 | packaged by conda-forge | (default, Jul 31 2020, 01:53:57) "
"[MSC v.1916 64 bit (AMD64)]"
)
- tmp_path.joinpath("pytask.ini").write_text(
- f"[pytask]\ncheck_python_version = {check_python_version}"
- )
+ tmp_path.joinpath(config_file).write_text(content.format(check_python_version))
source = "def task_dummy(): pass"
task_path = tmp_path.joinpath("task_dummy.py")
task_path.write_text(textwrap.dedent(source))
# Run without knowing the python version and without updating the environment.
result = runner.invoke(cli, [tmp_path.as_posix()])
- assert result.exit_code == 0
+ assert result.exit_code == ExitCode.OK
assert "Updating the information" in result.output
# Run with a fake version and not updating the environment.
@@ -128,20 +136,25 @@ def test_python_version_changed(
@pytest.mark.end_to_end
+@pytest.mark.parametrize(
+ "config_file, content",
+ [
+ ("pytask.ini", "[pytask]\ncheck_environment = {}"),
+ ("pyproject.toml", "[tool.pytask.ini_options]\ncheck_environment = {}"),
+ ],
+)
@pytest.mark.parametrize("check_python_version, expected", [("true", 1), ("false", 0)])
def test_environment_changed(
- monkeypatch, tmp_path, runner, check_python_version, expected
+ monkeypatch, tmp_path, runner, config_file, content, check_python_version, expected
):
- tmp_path.joinpath("pytask.ini").write_text(
- f"[pytask]\ncheck_environment = {check_python_version}"
- )
+ tmp_path.joinpath(config_file).write_text(content.format(check_python_version))
source = "def task_dummy(): pass"
task_path = tmp_path.joinpath("task_dummy.py")
task_path.write_text(textwrap.dedent(source))
# Run without knowing the python version and without updating the environment.
result = runner.invoke(cli, [tmp_path.as_posix()])
- assert result.exit_code == 0
+ assert result.exit_code == ExitCode.OK
assert "Updating the information" in result.output
# Run with a fake version and not updating the environment.
diff --git a/tox.ini b/tox.ini
index 15c3f82..ef14721 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,7 +4,6 @@ skipsdist = True
skip_missing_interpreters = True
[testenv]
-passenv = GITHUB_ACTIONS
basepython = python
[testenv:pytest]
@@ -19,10 +18,6 @@ commands =
pip install -e .
pytest {posargs}
-[doc8]
-ignore = D002, D004
-max-line-length = 88
-
[flake8]
docstring-convention = numpy
ignore =