---
source: crates/ruff_linter/src/rules/pylint/mod.rs
snapshot_kind: text
---
invalid_envvar_default.py:3:29: PLW1508 Invalid type for environment variable default; expected `str` or `None`
  |
1 | import os
2 | 
3 | tempVar = os.getenv("TEST", 12)  # [invalid-envvar-default]
  |                             ^^ PLW1508
4 | goodVar = os.getenv("TESTING", None)
5 | dictVarBad = os.getenv("AAA", {"a", 7})  # [invalid-envvar-default]
  |

invalid_envvar_default.py:5:31: PLW1508 Invalid type for environment variable default; expected `str` or `None`
  |
3 | tempVar = os.getenv("TEST", 12)  # [invalid-envvar-default]
4 | goodVar = os.getenv("TESTING", None)
5 | dictVarBad = os.getenv("AAA", {"a", 7})  # [invalid-envvar-default]
  |                               ^^^^^^^^ PLW1508
6 | print(os.getenv("TEST", False))  # [invalid-envvar-default]
7 | os.getenv("AA", "GOOD")
  |

invalid_envvar_default.py:6:25: PLW1508 Invalid type for environment variable default; expected `str` or `None`
  |
4 | goodVar = os.getenv("TESTING", None)
5 | dictVarBad = os.getenv("AAA", {"a", 7})  # [invalid-envvar-default]
6 | print(os.getenv("TEST", False))  # [invalid-envvar-default]
  |                         ^^^^^ PLW1508
7 | os.getenv("AA", "GOOD")
8 | os.getenv("AA", f"GOOD")
  |

invalid_envvar_default.py:10:17: PLW1508 Invalid type for environment variable default; expected `str` or `None`
   |
 8 | os.getenv("AA", f"GOOD")
 9 | os.getenv("AA", "GOOD" + "BAR")
10 | os.getenv("AA", "GOOD" + 1)
   |                 ^^^^^^^^^^ PLW1508
11 | os.getenv("AA", "GOOD %s" % "BAR")
12 | os.getenv("B", Z)
   |

invalid_envvar_default.py:14:17: PLW1508 Invalid type for environment variable default; expected `str` or `None`
   |
12 | os.getenv("B", Z)
13 | os.getenv("AA", "GOOD" if Z else "BAR")
14 | os.getenv("AA", 1 if Z else "BAR")  # [invalid-envvar-default]
   |                 ^^^^^^^^^^^^^^^^^ PLW1508
15 | os.environ.get("TEST", 12)  # [invalid-envvar-default]
16 | os.environ.get("TEST", "AA" * 12)
   |
