fix: resolve all Ruff linting errors (F403, F405, F401, E402, E722, F821)#209
Open
ennajari wants to merge 2 commits intoVectifyAI:mainfrom
Open
fix: resolve all Ruff linting errors (F403, F405, F401, E402, E722, F821)#209ennajari wants to merge 2 commits intoVectifyAI:mainfrom
ennajari wants to merge 2 commits intoVectifyAI:mainfrom
Conversation
…821) - Replace wildcard imports (`from .utils import *`) with explicit named imports in page_index.py, page_index_md.py, __init__.py, and run_pageindex.py, eliminating 79 F405 and 5 F403 violations - Add __all__ to __init__.py to properly declare the public re-exports - Fix import order in utils.py (E402): move yaml/Path/config imports before load_dotenv() call; sort stdlib imports alphabetically - Add missing `import re` in utils.py (F821) used by regex helpers - Replace bare `except:` with `except Exception:` in utils.py and `except ImportError:` in page_index_md.py (E722) - Remove unused `ModelSettings` import in examples/agentic_vectorless_rag_demo.py (F401) - Move `from pprint import pprint` before function definition in cookbook/agentic_retrieval.ipynb cell to fix E402 in notebooks - Auto-fix 22 additional errors: F541 (f-strings), E401 (multiple imports per line), F811 (redefined imports), F401 (unused imports) No breaking changes: all public APIs preserved; __all__ exposes the same symbols previously accessible via star import.
77c145f to
9fab668
Compare
- Migrate PyPDF2 (CVE-2023-36464) to pypdf>=4.0.0 - Replace generic Exception raises with RuntimeError in page_index.py - Fix float equality comparison: accuracy == 1.0 -> accuracy >= 1.0 - Rename unused parameters: N->n, doc->_doc, toc_page_list->_toc_page_list - Remove redundant continue statement in fix_incorrect_toc - Replace list(data.keys()) with data.keys() to avoid unnecessary copy - Fix star imports with explicit named imports in page_index_md.py - Replace bare except with except ImportError - Use asyncio.to_thread for async file I/O in md_to_tree - Add ruff.toml to exclude .claude worktree directory from linting - Fix E402, F401, F811 issues in notebooks and example files
Author
ContextThis PR is a follow-up to #192 (CLI improvements) and focuses exclusively on static analysis fixes — no logic changes. Tools used
Key changes
No public API changes. |
|
That's interesting for the project |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Fixes 120 → 0 Ruff linting errors across the codebase by addressing every violation category reported by
ruff check ..Changes by rule
F403 / F405 — Wildcard imports replaced with explicit imports
Replaced all
from .utils import *andfrom pageindex import *patterns with explicit named imports in:pageindex/page_index.pypageindex/page_index_md.pypageindex/__init__.py(also adds__all__for proper re-export)run_pageindex.pyThis makes all name dependencies explicit and eliminates undefined-name false positives.
F401 — Unused imports
__all__topageindex/__init__.pyso re-exported names (md_to_tree,PageIndexClient, etc.) are recognised as intentionalModelSettingsimport fromexamples/agentic_vectorless_rag_demo.py(only referenced in a commented-out line)E402 — Module-level import not at top of file
pageindex/utils.py: movedyaml,Path, andconfigimports before theload_dotenv()call; sorted stdlib imports alphabeticallycookbook/agentic_retrieval.ipynb: movedfrom pprint import pprintbefore the function definition inside the affected cellF821 — Undefined name
pageindex/utils.py: added missingimport re(used byget_first_start_page_from_textandget_last_start_page_from_text)E722 — Bare
exceptpageindex/utils.py:except:→except Exception:pageindex/page_index_md.py:except:→except ImportError:(this block handles relative vs absolute import fallback)Auto-fixed (22 errors)
Applied
ruff check --fixfor: F541 (f-strings without placeholders), E401 (multiple imports on one line), F811 (redefined-while-unused imports), F401 (simple unused imports).No breaking changes
__all__in__init__.pyexplicitly re-exports the same names previously available via star importtqdmoptional fallback is preserved inpage_index_md.pyVerification