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

Simplify test_can_read_toml_env_variable to work like other tests #5284

Merged
merged 4 commits into from Nov 9, 2021

Conversation

Pierre-Sassoulas
Copy link
Member

Type of Changes

Type
🔨 Refactoring

Description

See initial intent in #3839
This permit to not use the OptionManagerMixin directly, which is
problematic when it needs the function defined in Pylinter or
other classes.

Required for #4720

@Pierre-Sassoulas Pierre-Sassoulas added the Maintenance Discussion or action around maintaining pylint or the dev workflow label Nov 9, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.12.0 milestone Nov 9, 2021
@Pierre-Sassoulas Pierre-Sassoulas changed the title Simplify 'test_can_read_toml_env_variable' to work like other tests Simplify test_can_read_toml_env_variable to work like other tests Nov 9, 2021
@coveralls
Copy link

coveralls commented Nov 9, 2021

Pull Request Test Coverage Report for Build 1441747249

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 93.362%

Totals Coverage Status
Change from base Build 1439309442: 0.0%
Covered Lines: 13812
Relevant Lines: 14794

💛 - Coveralls

See initial intent in #3839
This permit to not use the OptionManagerMixin directly, which is
problematic when it needs the function defined in Pylinter or
other classes.
@Pierre-Sassoulas Pierre-Sassoulas force-pushed the simplify-toml-test-using-env-var branch 2 times, most recently from 37390e2 to 3e87888 Compare November 9, 2021 14:08
Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

Looks good (if two minor comments get resolved)!

Btw, I looked at #3839 and #4812 does not seem to test what is reported there imo. When I read that issue report I think the reporter implies that an environment variables is used within the config file. The test created in #4812 doesn't test a config file with env-variables inside the file, but rather when the file itself is a env-variable itself.
Let me know if you think I'm reading the initial report incorrectly, just thought I would let you know :)

tests/config/test_config.py Outdated Show resolved Hide resolved

def check_configuration_file_reader(
runner: Run,
expected_disabled=None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This needs typing. I think it is Optional[Set[str]]?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch !

@Pierre-Sassoulas
Copy link
Member Author

doesn't test a config file with env-variables inside the file, but rather when the file itself is a env-variable itself.

Readint this it seems it's the intended use case. But I don't think working env variable directly work. Doing this fail:

diff --git a/tests/config/test_config.py b/tests/config/test_config.py
index 8ce5d9b4..bef53913 100644
--- a/tests/config/test_config.py
+++ b/tests/config/test_config.py
@@ -120,11 +120,12 @@ def test_can_read_toml_env_variable(tmp_path: Path) -> None:
         """
 [tool.pylint."messages control"]
 disable = "logging-not-lazy,logging-format-interpolation"
-jobs = "10"
+jobs = "${pylint_jobs}"
 reports = "yes"
 """
     )
     env_var = "tmp_path_env"
     os.environ[env_var] = str(config_file)
+    os.environ["pylint_jobs"] = "10"
     run = get_runner_from_config_file(f"${env_var}")
     check_configuration_file_reader(run)

@Pierre-Sassoulas Pierre-Sassoulas merged commit 48a5556 into main Nov 9, 2021
@Pierre-Sassoulas Pierre-Sassoulas deleted the simplify-toml-test-using-env-var branch November 9, 2021 23:01
@DanielNoord
Copy link
Collaborator

Yeah, the test works for with the PR was trying to add but I wonder if that PR should have closed the issue.
In any case, do we want to support environment variables in the config file? If so, we should probably open an issue.

@Pierre-Sassoulas
Copy link
Member Author

do we want to support environment variables in the config file?

We could do it if someone open an issue. But it probably won't happen as we have a bazillion different ways to change options already (one of them being a global file, one of them is calling the command with the env variable directly it supersedes the config file value).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Discussion or action around maintaining pylint or the dev workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants