mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 13:25:17 +00:00

<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> Close #8123 ## Test Plan <!-- How was it tested? --> New test cases --------- Signed-off-by: harupy <hkawamura0130@gmail.com>
44 lines
544 B
Python
44 lines
544 B
Python
import os
|
|
|
|
# Bad
|
|
os.environ['foo']
|
|
|
|
os.environ.get('foo')
|
|
|
|
os.environ.get('foo', 'bar')
|
|
|
|
os.getenv('foo')
|
|
|
|
env = os.environ.get('foo')
|
|
|
|
env = os.environ['foo']
|
|
|
|
if env := os.environ.get('foo'):
|
|
pass
|
|
|
|
if env := os.environ['foo']:
|
|
pass
|
|
|
|
|
|
# Good
|
|
os.environ['FOO']
|
|
|
|
os.environ.get('FOO')
|
|
|
|
os.environ.get('FOO', 'bar')
|
|
|
|
os.getenv('FOO')
|
|
|
|
env = os.getenv('FOO')
|
|
|
|
if env := os.getenv('FOO'):
|
|
pass
|
|
|
|
env = os.environ['FOO']
|
|
|
|
if env := os.environ['FOO']:
|
|
pass
|
|
|
|
os.environ['https_proxy']
|
|
os.environ.get['http_proxy']
|
|
os.getenv('no_proxy')
|