---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
PLW1508 Invalid type for environment variable default; expected `str` or `None`
 --> invalid_envvar_default.py:3:29
  |
1 | import os
2 |
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 Invalid type for environment variable default; expected `str` or `None`
 --> invalid_envvar_default.py:5:31
  |
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]
  |                               ^^^^^^^^
6 | print(os.getenv("TEST", False))  # [invalid-envvar-default]
7 | os.getenv("AA", "GOOD")
  |

PLW1508 Invalid type for environment variable default; expected `str` or `None`
 --> invalid_envvar_default.py:6:25
  |
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]
  |                         ^^^^^
7 | os.getenv("AA", "GOOD")
8 | os.getenv("AA", f"GOOD")
  |

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

PLW1508 Invalid type for environment variable default; expected `str` or `None`
  --> invalid_envvar_default.py:14:17
   |
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]
   |                 ^^^^^^^^^^^^^^^^^
15 | os.environ.get("TEST", 12)  # [invalid-envvar-default]
16 | os.environ.get("TEST", "AA" * 12)
   |

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