tox-dev/pyproject-fmt

tox config file not found when using 0.11+

cheginit opened this issue · 15 comments

Up to version 0.10, pyroject-fmt worked fine. But after I updated it to 0.11 (or any version after that), I get this error when I run it with pre-commit:

ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found
Traceback (most recent call last):
  File "/Users/taher/.cache/pre-commit/repo1jf3rj0i/py_env-python3/bin/pyproject-fmt", line 8, in <module>
    sys.exit(run())
             ^^^^^
  File "/Users/taher/.cache/pre-commit/repo1jf3rj0i/py_env-python3/lib/python3.11/site-packages/pyproject_fmt/__main__.py", line 55, in run
    results = [_handle_one(config, opts) for config in opts.configs]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/taher/.cache/pre-commit/repo1jf3rj0i/py_env-python3/lib/python3.11/site-packages/pyproject_fmt/__main__.py", line 55, in <listcomp>
    results = [_handle_one(config, opts) for config in opts.configs]
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/taher/.cache/pre-commit/repo1jf3rj0i/py_env-python3/lib/python3.11/site-packages/pyproject_fmt/__main__.py", line 28, in _handle_one
    formatted = format_pyproject(config)
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/taher/.cache/pre-commit/repo1jf3rj0i/py_env-python3/lib/python3.11/site-packages/pyproject_fmt/formatter/__init__.py", line 26, in format_pyproject
    _perform(parsed, conf)
  File "/Users/taher/.cache/pre-commit/repo1jf3rj0i/py_env-python3/lib/python3.11/site-packages/pyproject_fmt/formatter/__init__.py", line 14, in _perform
    fmt_project(parsed, conf)
  File "/Users/taher/.cache/pre-commit/repo1jf3rj0i/py_env-python3/lib/python3.11/site-packages/pyproject_fmt/formatter/project.py", line 86, in fmt_project
    _add_py_classifiers(project)
  File "/Users/taher/.cache/pre-commit/repo1jf3rj0i/py_env-python3/lib/python3.11/site-packages/pyproject_fmt/formatter/project.py", line 45, in _add_py_classifiers
    supports = [(major, i) for i in range(minor, _get_max_version() + 1)]
                                                 ^^^^^^^^^^^^^^^^^^
  File "/Users/taher/.cache/pre-commit/repo1jf3rj0i/py_env-python3/lib/python3.11/site-packages/pyproject_fmt/formatter/project.py", line 24, in _get_max_version
    tox_environments = subprocess.check_output(["tox", "-aqq"], encoding="utf-8", text=True)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['tox', '-aqq']' returned non-zero exit status 1.
  Installing backend dependencies: started

PR welcome 👍

just started running into this as well

#90 apparently broke things by presuming tox, recent tox and/or tox config

its not clear to me how to properly fix it outside of opt-out/ignore

opt-out/ignore

👍

@RonnyPfannschmidt Can you please elaborate how to this with opt-out/ignore?

Ignore would mean to just ignore The tox error and Carry on, opt out would need to pass a configuration option trough to enable/disable usages

IMHO should ignore 👍

Is there an ignore option in pyproject-fmt that I need to enable?

Nope, but adding that functionality is a PR welcome.

Ah, ok. So, we can add something like ignore_tox and then pass conf.ignore_tox to _get_max_version so it returns _PY_MAX_VERSION?

No configuration needed. Just ignore errors IMHO 🤷

I see what you mean, I can do that, if interested.

After making the change, it ran without any issue for my use case.

Fixed with 1.0.0.