-
-
Couldn't load subscription status.
- Fork 1.2k
Open
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds decision 🔒Needs a decision before implemention or rejectionNeeds a decision before implemention or rejection
Milestone
Description
Bug description
If the input argument of os.getenv is of type builtins.str pylint complains with the error message os.getenv does not support builtins.str type argument (invalid-envvar-value). This should not be the case since builtins.str is a string. Which is the expected type like mentioned here: "Env manipulation functions support only string type arguments.".
This happens when the key value of the environment variable comes from a data class attribute. Example:
import os
from dataclasses import dataclass
from typing import Optional
@dataclass
class EnvVar:
"""Environment variable to be set."""
name: str
_initial_value: Optional[str] = None
def __post_init__(self):
"""Save current env var value in `self._initial_value`."""
self._initial_value = os.getenv(self.name)And the warning is related to os.getenv(self.name).
Command used
pylint env.pyPylint output
env.py:11:30 E1507 os.getenv does not support builtins.str type argument (invalid-envvar-value)Expected behavior
No warning raised when the input argument of os.getenv is builtins.str.
Pylint version
pylint 2.11.1
astroid 2.8.0
Python 3.9.4OS / Environment
mascOS Big Sur (Versin 11.5.2)
ybhaw
Metadata
Metadata
Assignees
Labels
False Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds decision 🔒Needs a decision before implemention or rejectionNeeds a decision before implemention or rejection