Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Configuration via tox.ini #2172

Closed
dciborow opened this issue Apr 30, 2021 · 16 comments
Closed

Support Configuration via tox.ini #2172

dciborow opened this issue Apr 30, 2021 · 16 comments
Labels
C: configuration CLI and configuration T: enhancement New feature or request

Comments

@dciborow
Copy link

Is your feature request related to a problem? Please describe.
Currently, all of my test configurations are colocated within my tox.ini file for my entire project, except for my black configuration for line count = 120, which is stored in our pyproject.toml, and is the only setting configured there.

Describe the solution you'd like A clear and concise description of what you want to
happen.
Instead of having path a pyproject.yml and a tox.ini, I would like to be able to include the black configurations directly with tox.ini.

Describe alternatives you've considered A clear and concise description of any
alternative solutions or features you've considered.
I can't seem to find any single type of configuration file that works for pytest, pylint, bandit, flake8, and black. Tox is supported by the most of these, so I am trying to chase this down.

@dciborow dciborow added the T: enhancement New feature or request label Apr 30, 2021
@ichard26 ichard26 added the C: configuration CLI and configuration label Apr 30, 2021
@dciborow
Copy link
Author

Currently... we are able to put this in a plain tox.ini, and everything works.

image

It is only when we add more things to tox.ini, that it stops working.
image

@JelleZijlstra
Copy link
Collaborator

I don't think we should do this. pyproject.toml is a standard(ish) way of configuring Python tools, while tox.ini is specific to Tox. Instead, other tools should move towards allowing configuration through pyproject.toml.

@dciborow
Copy link
Author

dciborow commented Apr 30, 2021

@JelleZijlstra ,

Do you happen to know what about the pyproject.toml standard is different then the tox.ini standard? Particularly why the header names I use in tox.ini seem to break black's ability to process the tox.ini?

If someone added something like this to their pyproject.toml, it would also start to cause black to fail. But I am not familiar enough with pyproject.toml's standard to understand what makes it incompatible?

[mypy]
python_version = 3.7
ignore_missing_imports = True
strict_optional = False
follow_imports = silent

so, a different way to look at this... Should an existence of a misconfiguration in a different setting break black in the pyproject.toml?

@JelleZijlstra
Copy link
Collaborator

Not too familiar with it, but obviously one is in TOML format (which is a standardized language) and one is in .ini format, which I think is just whatever Python's configparser module accepts.

@dciborow
Copy link
Author

dciborow commented Apr 30, 2021

Also, there is negative traction towards expand pyproject.toml to other tools, particularly mypy. But going to chat in that thread and see if mindset has changed at all.

image

python/mypy#5205

@JelleZijlstra
Copy link
Collaborator

Actually mypy is about to gain support for pyproject.toml (python/mypy#10219).

@ichard26
Copy link
Collaborator

ichard26 commented Apr 30, 2021

@dciborow I don't use Tox so I wouldn't know for sure, but the main difference causing them to be incompatible is probably that tox.ini uses the INI file format which is different enough from the TOML file format. pyproject.toml is just a normal TOML file who's contents has been somewhat standardized for Python's packaging usage (and now also tools under the [tool.*] namespace).

I don't think our TOML parser can just ignore a misconfigured value / table. That sounds complicated and prone to errors. In your case, the problem is that booleans values must be lowercase in TOML. And allowing Black to run even when the configuration fails to parse sounds dangerous. It could format files it should never format because it was unable to read the exclude option configured in that invalid file.

@dciborow
Copy link
Author

@ichard26 ,

Understand the points you are presenting. But to be super clear, the black configuration between the two files is identical.

So to be clear on the reverse point that I am trying to make... if a pyproject.toml is misconfigured outside of the [tools.black] section, you would expect black to fail? Even when the black section is completely correct and readable by black?
I think the below case fails just because [mypy] is missing "tool.".
Where I am proposing black can ignore those sections, instead of failing on them.

pyproject.toml

[mypy]
python_version = 3.7
ignore_missing_imports = true
strict_optional = false
follow_imports = silent

[tool.black]
line-length = 120
fast = true

@JelleZijlstra
Copy link
Collaborator

We're just using a TOML parser. If the TOML is valid, we use it. If it's not valid, we don't, because we can't.

@dciborow dciborow reopened this Apr 30, 2021
@dciborow
Copy link
Author

okay... let me do some more debugging... see if its something else in my .ini thats messing this up.

It sounds like @JelleZijlstra , you would not expect the above sample to fail for black, given it was a valid TOML...?

@dciborow
Copy link
Author

dciborow commented Apr 30, 2021

ahhh turns out this was my problem line.
tox.ini allows...
follow_imports = silent

But pyproject.yml wants
follow_imports = 'silent'

and 'silent' breaks .ini
image

@felix-hilden
Copy link
Collaborator

For context, Tox is adding pyproject.toml configuration too (see tox-dev/tox#999). That doesn't mean that all the other tools using tox.ini will though, but that's something at least. I don't think expanding functionality back to tox.ini is worth it anymore.

@ambv
Copy link
Collaborator

ambv commented May 4, 2021

We don't support multiple potential configuration files as this creates terrible precedence rules. There's been heated discussions about similar ideas before, we're not doing it.

@ambv ambv closed this as completed May 4, 2021
@mcarans
Copy link

mcarans commented Oct 13, 2021

This is a shame. I can configure flake8 and isort in tox.ini but not black.

@ikus060
Copy link

ikus060 commented Mar 14, 2022

This is a shame. I can configure flake8 and isort in tox.ini but not black.

Completely agree. Adding configuration to tox.ini is a defactor standard. Also pyproject.toml is fearly new and is not supported by older setuptools. In my project when trying to create the file pyproject.toml all our build start failing because of mysterious incompatibility.

@mcarans
Copy link

mcarans commented Mar 15, 2022

@ikus060 I've since moved to a full pyproject.toml setup by resurrecting flakehell, a wrapper around flake8 with nice pyproject.toml support that had become unmaintained, as flakeheaven in case this is helpful to your project.

evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `check-format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `check-format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `check-format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
evanpurkhiser added a commit to evanpurkhiser/croniter that referenced this issue Oct 30, 2024
- Adds a new tox `check-format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
kiorky pushed a commit to corpusops/croniter that referenced this issue Oct 31, 2024
- Adds a new tox `check-format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
kiorky pushed a commit to corpusops/croniter that referenced this issue Dec 16, 2024
- Adds a new tox `check-format` command
- Locks black to the last version supporting python 2
- Configures black using pyproject.toml (unfortunately it cannot be
  configured using tox.ini, see psf/black#2172)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: configuration CLI and configuration T: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants