astral-sh / astral-sh/ruff

Rewrite `os.environ.get` as `os.getenv`

Open
#3,608 7 comments 6 reactions 0 assignees View on GitHub
needs-decision rule
Dominant language
Rust
Stars
49.7k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
458

Description

**Bad**

```py
os.environ.get(secret)
os.environ.get(secret, "fallback")
```

**Good**

```py
os.getenv(secret)
os.getenv(secret, "fallback")
```

Contributor guide

Open the contributing guide

Research direction

Start by locating Ruff's implementation and tests for rules that rewrite Python expressions involving os.environ. Verify how the rule recognizes both one-argument and fallback forms shown in the issue, and confirm that the resulting code uses os.getenv with equivalent arguments.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.