Skip to content

Doit ignores action_string_formatting config when defined in pyproject.toml #464

@Alexandre-Silva

Description

@Alexandre-Silva

Describe the bug

Doit ignores action_string_formatting = "new" when defined in pyproject.toml. It uses the default value 'old'. However, when defining it directly in the doit.py it works as expected. The bug persists when using doit.cfg.

I did some crude debugging and if params.update_defaults(self.config_vals) is added at the start of DoItCmdBase.execute(), then the issue disappears.

Note that I'm extremely unexperienced with doit, so this may be user error. But the included files follow directly what is in the documentation (pyproject-toml, keywords on cmd-action string). So it may instead be a documentation problem instead of bug.

# pyproject.toml
[tool.poetry]
name = "alex-pydoit"
version = "0.1.0"
description = ""
authors = ["Alexandre-Silva <[email protected]>"]
readme = "README.md"
packages = [{include = "alex_pydoit"}]

[tool.poetry.dependencies]
python = "^3.9"
doit = "^0.36.0"
pygraphviz = "^1.11"
import-deps = "^0.2.0"

[tool.poetry.group.dev.dependencies]
tomli = "^2.0.1"
toml = "^0.10.2"

[tool.doit]
action_string_formatting = "new"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
# dodo.py

# if uncommented then it works fine
# DOIT_CONFIG = {'action_string_formatting': "new"}

def task_imports():
    """find imports from a python module"""
    return {
        'file_dep': ['some/file.py'],
        'targets': ['out.deps'],
        'actions': ['python -m import_deps {dependencies} > {targets}'],
    }
$doit imports
doit imports
.  imports
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/alex/.cache/pypoetry/virtualenvs/alex-pydoit-98aUlDd0-py3.11/lib/python3.11/site-packages/import_deps/__main__.py", line 15, in <module>
    main(sys.argv[1])
  File "/home/alex/.cache/pypoetry/virtualenvs/alex-pydoit-98aUlDd0-py3.11/lib/python3.11/site-packages/import_deps/__main__.py", line 7, in main
    module = PyModule(module_path)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/alex/.cache/pypoetry/virtualenvs/alex-pydoit-98aUlDd0-py3.11/lib/python3.11/site-packages/import_deps/__init__.py", line 50, in __init__
    assert self.path.suffix == '.py'
           ^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
TaskFailed - taskid:imports
Command failed: 'python -m import_deps {dependencies} > {targets}' returned 1

########################################
imports <stdout>:

Environment

  1. OS: Arch Linux, Linux 6.6.3-arch1-1, x86-64
  2. python version: 3.11.6
  3. doit version: 0.36.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions