From fd7f65e0acbcd27978fccba29e218afe0e345d6d Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 19 Nov 2025 06:44:56 +0000 Subject: [PATCH] Fix SIM102: Combine nested if statements using 'and' Combined nested if statements in TextParser._read_source() method to improve code readability and follow ruff linting guidelines. --- tableqa/metadata/parsers/text.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tableqa/metadata/parsers/text.py b/tableqa/metadata/parsers/text.py index 21e8bf2..6aa439b 100644 --- a/tableqa/metadata/parsers/text.py +++ b/tableqa/metadata/parsers/text.py @@ -65,15 +65,14 @@ def _read_source(self, source: str | Path) -> str: """Read content from source.""" if isinstance(source, Path): return source.read_text(encoding="utf-8") - if isinstance(source, str): - # Check if it looks like a file path (not too long and no newlines) - if len(source) < 4096 and "\n" not in source: - path = Path(source) - try: - if path.exists() and path.is_file(): - return path.read_text(encoding="utf-8") - except (OSError, ValueError): - pass + # Check if it looks like a file path (not too long and no newlines) + if isinstance(source, str) and len(source) < 4096 and "\n" not in source: + path = Path(source) + try: + if path.exists() and path.is_file(): + return path.read_text(encoding="utf-8") + except (OSError, ValueError): + pass # Treat as string content return str(source)