Skip to content

Conversation

Aearsears
Copy link

@Aearsears Aearsears commented Aug 19, 2025

Type of Changes

Type
βœ“ πŸ› Bug fix
✨ New feature
πŸ”¨ Refactoring
πŸ“œ Docs

Description

This PR updates the StdLibchecker to check for invalid-envvar-default and invalid-envvar-value when calling os.environ.get. os.environ is a mapping object and it calls concretely builtins.dict 's get method

Relates to PR #10094

Closes #10092

@Aearsears
Copy link
Author

should I create a news fragment for this change?

@Pierre-Sassoulas
Copy link
Member

Yes, indeed :) thank you for the MR, I skimmed and i've seen nothing shocking, will review in depth later. Great first contribution !

This comment has been minimized.

@Pierre-Sassoulas
Copy link
Member

Seeing the messages in the primer, we should probably not raise for int(os.get.environ("SOMETHING", 1) or float(os.get.environ("SOMETHING", 1.0), but let's remember that it's the work of a type checker to warn about this not pylint, and type checkers exists. (Don't want to discourage you, and you did great work, but they are more value in fixing other checks and other bugs in the backlog)

@Aearsears
Copy link
Author

Aearsears commented Aug 23, 2025

thanks for the review Pierre-Sassoulas, i'll see if I can find a quick solution to what you mentioned, otherwise i'll close this pr and contribute to other issues as you suggested

@Aearsears Aearsears force-pushed the flag-os-environ-get branch from 5f36561 to 1b65560 Compare August 23, 2025 18:49
@Aearsears Aearsears marked this pull request as ready for review August 23, 2025 22:12
Copy link

codecov bot commented Sep 11, 2025

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 95.85%. Comparing base (a52dd58) to head (3b0fac2).
⚠️ Report is 29 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10507   +/-   ##
=======================================
  Coverage   95.85%   95.85%           
=======================================
  Files         177      177           
  Lines       19284    19293    +9     
=======================================
+ Hits        18484    18493    +9     
  Misses        800      800           
Files with missing lines Coverage Ξ”
pylint/checkers/stdlib.py 96.38% <100.00%> (+0.11%) ⬆️
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

πŸ€– Effect of this PR on checked open source code: πŸ€–

Effect on sentry:
The following messages are now emitted:

  1. invalid-envvar-default:
    os.environ.get default type is builtins.bool. Expected str or None.
    https://github.com/getsentry/sentry/blob/cd3fcd3738d0f530e00c2eed8318cae4af3b6745/src/sentry/apidocs/utils.py#L74
  2. invalid-envvar-default:
    os.environ.get default type is builtins.bool. Expected str or None.
    https://github.com/getsentry/sentry/blob/cd3fcd3738d0f530e00c2eed8318cae4af3b6745/src/sentry/conf/server.py#L736
  3. invalid-envvar-default:
    os.environ.get default type is builtins.bool. Expected str or None.
    https://github.com/getsentry/sentry/blob/cd3fcd3738d0f530e00c2eed8318cae4af3b6745/src/sentry/conf/server.py#L1966
  4. invalid-envvar-default:
    os.environ.get default type is builtins.bool. Expected str or None.
    https://github.com/getsentry/sentry/blob/cd3fcd3738d0f530e00c2eed8318cae4af3b6745/src/sentry/conf/server.py#L2978
  5. invalid-envvar-default:
    os.environ.get default type is builtins.bool. Expected str or None.
    https://github.com/getsentry/sentry/blob/cd3fcd3738d0f530e00c2eed8318cae4af3b6745/src/sentry/conf/server.py#L3018
  6. invalid-envvar-default:
    os.environ.get default type is builtins.bool. Expected str or None.
    https://github.com/getsentry/sentry/blob/cd3fcd3738d0f530e00c2eed8318cae4af3b6745/src/sentry/conf/server.py#L3135
  7. invalid-envvar-default:
    os.environ.get default type is builtins.bool. Expected str or None.
    https://github.com/getsentry/sentry/blob/cd3fcd3738d0f530e00c2eed8318cae4af3b6745/src/sentry/conf/server.py#L3879
  8. invalid-envvar-default:
    os.environ.get default type is builtins.bool. Expected str or None.
    https://github.com/getsentry/sentry/blob/cd3fcd3738d0f530e00c2eed8318cae4af3b6745/src/sentry/runner/settings.py#L129

This comment was generated for commit 3b0fac2

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.

Question: Is there a reason that invalid-envvar-default only checks os.getenv, not os.environ.get
2 participants