-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
refactor config file finding #8358
base: main
Are you sure you want to change the base?
refactor config file finding #8358
Conversation
fe3b062
to
cbee643
Compare
The discussion in #3523 is interesting, seems this will bring a lot of pain to our users that still keep their configuration in What would be the downsides of keeping the existing support, even if for some options it doesn't work so well ( |
@nicoddemus in that case lets turn in future we might want to try using config-parser to load based on recent developments of config-parser it may even be possible o drop inconfig and use different config-parser configurations for different config-file setups as part of a breaking release |
I would be fine with that. 👍 We can remove examples of
I'm not keen on the details, but the overall idea seems good. 😁 |
cbee643
to
015fcf4
Compare
reviewed the docs and decided the warnings @nicoddemus did put in way earlier are good enough |
ed2ac09
to
7129605
Compare
8ebc068
to
c6f6e59
Compare
its already taken care of earlier
c6f6e59
to
4ac06da
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the changes look good, please take a look at my comments. 👍
@@ -79,7 +79,7 @@ and can also be used to hold pytest configuration if they have a ``[pytest]`` se | |||
.. code-block:: ini | |||
|
|||
# tox.ini | |||
[pytest] | |||
[tool:pytest] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right, AFAIK for tox.ini
files we use the [pytest]
section.
down problems. | ||
When possible, it is recommended to use the latter files, or ``pyproject.toml``, to hold your | ||
pytest configuration. | ||
``setup.cfg`` file usage for pytest has been deprecated, its recommended to use ``tox.ini`` or ``pyproject.toml`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
``setup.cfg`` file usage for pytest has been deprecated, its recommended to use ``tox.ini`` or ``pyproject.toml`` | |
``setup.cfg`` file usage for pytest is supported but is not recommended for new projects. Instead, use ``tox.ini`` or ``pyproject.toml`` files. |
It is not really deprecated in the sense that we will remove it in the future.
) -> Optional[Dict[str, Union[str, List[str]]]]: | ||
"""Load pytest configuration from the given file path, if supported. | ||
def _parse_pytest_ini(path: Path) -> PARSE_RESULT: | ||
"""Parse the legacy pytest.ini and return the contents of the pytest section |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Parse the legacy pytest.ini and return the contents of the pytest section | |
"""Parse the pytest.ini file and return the contents of the pytest section |
I don't think we should consider pytest.ini
files "legacy" in any way. 😁
return None | ||
|
||
|
||
def locate_config( | ||
args: Iterable[Path], | ||
args: List[Path], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, but for non-mutable parameters I think Sequence
is more adequate.
@@ -113,7 +113,7 @@ def test_tox_ini_wrong_version(self, pytester: Pytester) -> None: | |||
@pytest.mark.parametrize( | |||
"section, name", | |||
[ | |||
("tool:pytest", "setup.cfg"), | |||
pytest.param("tool:pytest", "setup.cfg"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unnecessary?
|
||
Return None if the file does not contain valid pytest configuration. | ||
if the file exists and lacks a pytest section, consider it empty""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the file exists and lacks a pytest section, consider it empty""" | |
if the file exists and lacks a pytest section, consider it empty.""" |
|
||
|
||
def _parse_ini_file(path: Path) -> PARSE_RESULT: | ||
"""Parses .ini files with expected pytest.ini sections |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Parses .ini files with expected pytest.ini sections | |
"""Parses .ini files with expected pytest.ini sections. |
def _parse_ini_file(path: Path) -> PARSE_RESULT: | ||
"""Parses .ini files with expected pytest.ini sections | ||
|
||
todo: investigate if tool:pytest should be added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: investigate if tool:pytest should be added | |
TODO: Investigate if tool:pytest should be added. |
However I think it would be best to either create a new issue, or write more details about what you mean with this "TODO" (or is this something you still plan to work on this PR?).
addresses #3523
setup.cfg
also a structural refactor and cleanup of the config file finding/loading