mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 10:48:32 +00:00
Treat os.error
as an OSError
alias (#7582)
Closes https://github.com/astral-sh/ruff/issues/7580.
This commit is contained in:
parent
74dbd871f8
commit
a51b0b02f0
3 changed files with 30 additions and 1 deletions
|
@ -104,3 +104,12 @@ def get_owner_id_from_mac_address():
|
|||
mac_address = get_primary_mac_address()
|
||||
except(IOError, OSError) as ex:
|
||||
msg = 'Unable to query URL to get Owner ID: {u}\n{e}'.format(u=owner_id_url, e=ex)
|
||||
|
||||
|
||||
# Regression test for: https://github.com/astral-sh/ruff/issues/7580
|
||||
import os
|
||||
|
||||
try:
|
||||
pass
|
||||
except os.error:
|
||||
pass
|
||||
|
|
|
@ -61,7 +61,7 @@ fn is_alias(expr: &Expr, semantic: &SemanticModel) -> bool {
|
|||
matches!(
|
||||
call_path.as_slice(),
|
||||
["", "EnvironmentError" | "IOError" | "WindowsError"]
|
||||
| ["mmap" | "select" | "socket", "error"]
|
||||
| ["mmap" | "select" | "socket" | "os", "error"]
|
||||
)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -281,5 +281,25 @@ UP024_0.py:105:11: UP024 [*] Replace aliased errors with `OSError`
|
|||
105 |- except(IOError, OSError) as ex:
|
||||
105 |+ except OSError as ex:
|
||||
106 106 | msg = 'Unable to query URL to get Owner ID: {u}\n{e}'.format(u=owner_id_url, e=ex)
|
||||
107 107 |
|
||||
108 108 |
|
||||
|
||||
UP024_0.py:114:8: UP024 [*] Replace aliased errors with `OSError`
|
||||
|
|
||||
112 | try:
|
||||
113 | pass
|
||||
114 | except os.error:
|
||||
| ^^^^^^^^ UP024
|
||||
115 | pass
|
||||
|
|
||||
= help: Replace `os.error` with builtin `OSError`
|
||||
|
||||
ℹ Fix
|
||||
111 111 |
|
||||
112 112 | try:
|
||||
113 113 | pass
|
||||
114 |-except os.error:
|
||||
114 |+except OSError:
|
||||
115 115 | pass
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue