Skip to content

Commit

Permalink
fix the logging.exception in _utils.py, add LOG015 and ruff docs link…
Browse files Browse the repository at this point in the history
… to linting rules, add noqa to make_switcher.py
  • Loading branch information
rerpha committed Nov 29, 2024
1 parent 5544e90 commit 38b5e02
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/pages/make_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_versions(ref: str, add: str | None) -> list[str]:
builds = set(get_branch_contents(ref))
except CalledProcessError:
builds = set()
logging.warning(f"Cannot get {ref} contents")
logging.warning(f"Cannot get {ref} contents") # noqa: LOG015

# Add and remove from the list of builds
if add:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ lint.select = [
"UP", # pyupgrade - https://docs.astral.sh/ruff/rules/#pyupgrade-up
"SLF", # self - https://docs.astral.sh/ruff/settings/#lintflake8-self
"PLC2701", # private import - https://docs.astral.sh/ruff/rules/import-private-name/
"LOG015", # root logger call - https://docs.astral.sh/ruff/rules/root-logger-call/
]
lint.preview = true # so that preview mode PLC2701 is enabled

Expand Down
4 changes: 3 additions & 1 deletion src/ophyd_async/core/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
DEFAULT_TIMEOUT = 10.0
ErrorText = str | Mapping[str, Exception]

logger = logging.getLogger("ophyd_async")


class StrictEnumMeta(EnumMeta):
def __new__(metacls, *args, **kwargs):
Expand Down Expand Up @@ -114,7 +116,7 @@ def with_other_exceptions_logged(
) -> NotConnected:
for name, exception in exceptions.items():
if not isinstance(exception, NotConnected):
logging.exception(
logger.exception(
f"device `{name}` raised unexpected exception "
f"{type(exception).__name__}",
exc_info=exception,
Expand Down

0 comments on commit 38b5e02

Please sign in to comment.