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

refactor config file finding #8358

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

RonnyPfannschmidt
Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt commented Feb 20, 2021

addresses #3523

setup.cfg

also a structural refactor and cleanup of the config file finding/loading

  • changelog
  • writeup in deprecated docs/links

@RonnyPfannschmidt RonnyPfannschmidt force-pushed the ronny/fix-3523-deprecate-setup-cfg branch from fe3b062 to cbee643 Compare February 20, 2021 21:25
@nicoddemus
Copy link
Member

The discussion in #3523 is interesting, seems this will bring a lot of pain to our users that still keep their configuration in setup.cfg, because those that have working suites today are not being affected by the issues in #3523, so I wonder if there's other path than dropping setup.cfg support completely?

What would be the downsides of keeping the existing support, even if for some options it doesn't work so well (filterwarnings seems to be an example of that)?

@RonnyPfannschmidt
Copy link
Member Author

@nicoddemus in that case lets turn setup.cfg support into something undocumented, and keep support based on the basic testing

in future we might want to try using config-parser to load setup.cfg data

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

@nicoddemus
Copy link
Member

@nicoddemus in that case lets turn setup.cfg support into something undocumented, and keep support based on the basic testing

I would be fine with that. 👍

We can remove examples of setup.cfg usage, and just leave a note stating that while it "works", there are situations where it doesn't and is not really recommended. This way if any bug reports come along because of setup.cfg support, we can just point that to users and suggest they change the configuration format.

in future we might want to try using config-parser to load setup.cfg data

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'm not keen on the details, but the overall idea seems good. 😁

Base automatically changed from master to main March 9, 2021 20:40
@RonnyPfannschmidt RonnyPfannschmidt force-pushed the ronny/fix-3523-deprecate-setup-cfg branch from cbee643 to 015fcf4 Compare June 6, 2021 20:39
@RonnyPfannschmidt
Copy link
Member Author

reviewed the docs and decided the warnings @nicoddemus did put in way earlier are good enough

@RonnyPfannschmidt RonnyPfannschmidt changed the title refactor config file finding and deprecate setup.cfg refactor config file finding Jun 6, 2021
@RonnyPfannschmidt RonnyPfannschmidt marked this pull request as ready for review June 6, 2021 20:51
@RonnyPfannschmidt RonnyPfannschmidt marked this pull request as draft October 3, 2021 18:44
@RonnyPfannschmidt RonnyPfannschmidt force-pushed the ronny/fix-3523-deprecate-setup-cfg branch 2 times, most recently from ed2ac09 to 7129605 Compare July 12, 2022 08:08
@RonnyPfannschmidt RonnyPfannschmidt marked this pull request as ready for review July 12, 2022 08:08
@RonnyPfannschmidt RonnyPfannschmidt force-pushed the ronny/fix-3523-deprecate-setup-cfg branch from 8ebc068 to c6f6e59 Compare July 12, 2022 08:44
@RonnyPfannschmidt RonnyPfannschmidt force-pushed the ronny/fix-3523-deprecate-setup-cfg branch from c6f6e59 to 4ac06da Compare July 29, 2022 19:51
Copy link
Member

@nicoddemus nicoddemus left a 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]
Copy link
Member

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``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
``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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""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],
Copy link
Member

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"),
Copy link
Member

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"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?).

@RonnyPfannschmidt RonnyPfannschmidt marked this pull request as draft July 31, 2022 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants