mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:43 +00:00

## Summary Expands several rules to also check for `Expr::Name` values. As they would previously not consider: ```python from logging import error error("foo") ``` as potential violations ```python import logging logging.error("foo") ``` as potential violations leading to inconsistent behaviour. The rules impacted are: - `BLE001` - `TRY400` - `TRY401` - `PLE1205` - `PLE1206` - `LOG007` - `G001`-`G004` - `G101` - `G201` - `G202` ## Test Plan Fixtures for all impacted rules expanded. ## Issue Link Refers: https://github.com/astral-sh/ruff/issues/7502
24 lines
629 B
Python
24 lines
629 B
Python
import logging
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
logging.exception("foo") # OK
|
|
logging.exception("foo", exc_info=False) # LOG007
|
|
logging.exception("foo", exc_info=[]) # LOG007
|
|
logger.exception("foo") # OK
|
|
logger.exception("foo", exc_info=False) # LOG007
|
|
logger.exception("foo", exc_info=[]) # LOG007
|
|
logger.error("foo", exc_info=False) # OK
|
|
logger.info("foo", exc_info=False) # OK
|
|
|
|
|
|
from logging import exception
|
|
|
|
exception("foo", exc_info=False) # LOG007
|
|
exception("foo", exc_info=True) # OK
|
|
|
|
|
|
exception = lambda *args, **kwargs: None
|
|
|
|
exception("foo", exc_info=False) # OK
|
|
exception("foo", exc_info=True) # OK
|