From af591140b6ca5aa90e1b8cd6537e9e5aa4eebc2f Mon Sep 17 00:00:00 2001 From: Patrick Ogenstad Date: Sun, 30 Jun 2024 13:07:28 +0200 Subject: [PATCH] Fix Ruff TRY300: Consider moving this statement to an `else` block --- nornir/core/inventory.py | 3 +-- pyproject.toml | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/nornir/core/inventory.py b/nornir/core/inventory.py index fcff2c76..3a90313d 100644 --- a/nornir/core/inventory.py +++ b/nornir/core/inventory.py @@ -339,8 +339,7 @@ def __getitem__(self, item: str) -> Any: except KeyError: for g in self.extended_groups(): try: - r = g.data[item] - return r + return g.data[item] except KeyError: continue diff --git a/pyproject.toml b/pyproject.toml index 5ef74ddf..ec8d0384 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -167,7 +167,6 @@ ignore = [ "TRY002", # Create your own exception "TRY003", # Avoid specifying long messages outside the exception class "TRY004", # Prefer `TypeError` exception for invalid type - "TRY300", # Consider moving this statement to an `else` block "TRY400", # Use `logging.exception` instead of `logging.error` "UP004", # Class inherits from `object` "UP009", # UTF-8 encoding declaration is unnecessary