Skip to content

os-error-alias does not include os.error #7580

@Avasam

Description

@Avasam

os.error is an alias for OSError, but is not standardized as part of https://docs.astral.sh/ruff/rules/os-error-alias/

>>> import os; OSError is os.error
True
import os

try:
    pass
except (WindowsError, os.error):
    pass

becomes:

import os

try:
    pass
except (OSError, os.error):
    pass

expected:

import os  # This import is now unused and can be removed

try:
    pass
except OSError:
    pass

This would be a deviation from pyupgrade, I have opened the same request in parallel: asottile/pyupgrade#892
Edit: This was just added in asottile/pyupgrade#893

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions