-
Notifications
You must be signed in to change notification settings - Fork 25
Bug Fixes and Modernization #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Fix critical bug where get_repo_map() tuple was not unpacked, causing TypeError when tool attempted to count tokens. This prevented any output when installed via uvx. Additionally migrate to modern Python packaging: - Convert to src/ layout with hatch build system - Fix missing queries/ directory in package distribution - Modernize type hints (PEP 604, 585) - Add ruff linting configuration - Fix undefined variables and bare except clauses The queries directory is now properly included, fixing 0 definitions/ 0 references issue when parsing files. See PR description for detailed breakdown of all changes, rationale, and testing verification.
Generates just a list of files in the directory
This comment was marked as outdated.
This comment was marked as outdated.
|
Let me know if you like this, but want it split up. You can try it using:
|
|
If you eventually wanted to publish to pypi, then I'd suggest taking a look at copying over examples in https://github.com/jlevy/simple-modern-uv/tree/main (which I could help with) |
This caused PageRange to fail
1. repomap_class.py: Replaced generate_overview_only with generate_outline
- Extracts symbols via tree-sitter
- Lists definitions (classes/functions) with line numbers
- Skips PageRank (faster than full map)
2. repomap.py: Renamed --overview to --outline with updated help text
3. README.md: Updated the example
Output format:
src\repomapper\repomap_class.py
FileReport (23)
RepoMap (37)
__init__ (40)
load_tags_cache (80)
...
src\repomapper\utils.py
Tag (16)
count_tokens (19)
read_text (33)
README.md:
- Updated installation section from pip install -r requirements.txt to use uv sync and uv pip install -e .
- The old requirements.txt didn't even exist; the project uses pyproject.toml
src/repomapper/repomap.py:
- Fixed --outline mode to include files from --chat-files (previously only --other-files and positional args were
used)
- Moved the "Chat files:" print to only execute in non-outline mode
CLI args with --outline:
- --chat-files and positional args/--other-files now all work correctly with --outline
- Args like --mentioned-files, --mentioned-idents, --force-refresh, --exclude-unranked, --map-tokens,
--max-context-window have no effect in outline mode (they're for PageRank which outline skips) but this is by design -
outline is a simpler/faster mode
Updated readme to use `uv...`
|
That's all I'm gonna change. Again, there's probably a way I can split it up better... sorry about adding/removing the overview/outline feature. Once I fixed the missing scipy import, I realized the low value of adding another arg and displaying not-show files |
Now that I have everything working, it's not very useful! 1. src/repomapper/repomap.py - Removed the --outline CLI argument and its handling code 2. src/repomapper/repomap_class.py - Removed the generate_outline() method 3. README.md - Removed the outline usage documentation
|
The 1 functional thing I did was use PageRank regardless of personalization, so ‘repomapper .” still ranks output, even without —chat-files |
Hi. This is a massive pr, and honestly it's ok if you don't accept.
I wanted to add as a dev dependency to my app, so I could run
uv run repomapper .First I addedrepomapper = "repomap:main"to the pyproject.toml and tried. The python version you specified>=3.13wasn't compatible with mine. Ok, so try douvx --from "git+https://github.com/pdavis68/RepoMapper.git" repomapper .Didn't work. Fired up Claude Code. It quickly identified that thequeries/wasn't being included when using uvx. I directed it to move code to more typical file structure, setup-tools -> hatch, add ruff linting, and fix the remaining few things ruff reported.I should have done this across a few commits. Sorry... I thought of that just after I ran the Ruff fixes after moving the directories. But I did have Claude generate a report so you can follow along. Hope this is helpful.
RepoMapper: Bug Fixes and Modernization
Executive Summary
This PR addresses a critical bug that prevented RepoMapper from generating any output when installed via
uvx, and modernizes the codebase to use standard Python packaging practices and current type hint syntax.Root Cause Analysis
Issue 1: Tuple Unpacking Bug
When running
uvx --from "git+https://github.com/..." repomapper ., the tool would fail with:Root Cause: In
repomap.py:200, the code was not unpacking the tuple returned byget_repo_map():The method
get_repo_map()returns a tuple(map_string, file_report), but the code assigned the entire tuple tomap_content. Since a non-empty tuple is always truthy, it would attempt to count tokens on the tuple object, causing a TypeError.Issue 2: Missing Package Data
When installed via git with uvx, the
queries/directory containing.scmtree-sitter query files was not included in the package. This caused 0 definitions and 0 references to be found (since tree-sitter couldn't parse any files without the query definitions).Root Cause: The project used
py-modulesin setuptools, which doesn't have a standard way to include package data. Thequeries/directory was never being packaged.Solution Approach
src/layout with hatch build systemManual Changes (Detailed)
1. Package Structure Conversion
Rationale: The
py-modulesapproach is deprecated. Modern Python projects usesrc/layout with proper package structure, which provides better isolation, testing, and packaging reliability.Changes:
src/repomapper/directory.pyfiles from root tosrc/repomapper/queries/directory tosrc/repomapper/queries/src/repomapper/__init__.pywith version info2. Build System Migration
File:
pyproject.tomlBefore:
After:
Rationale: Hatchling is the modern, recommended build backend. It automatically handles package data within the package directory and has simpler configuration.
3. Critical Bug Fix: Tuple Unpacking
File:
src/repomapper/repomap.py:200Before:
After:
Rationale:
get_repo_map()returnstuple[str|None, FileReport]. Must unpack to access the string component.Additional Enhancement: Added verbose output for file report when no map is generated:
4. Import Path Updates
Rationale: Moving to
src/repomapper/package structure requires all internal imports to be relative.Changed in ALL files:
Files Modified:
src/repomapper/repomap.pysrc/repomapper/repomap_class.pysrc/repomapper/repomap_server.py5. Console Script Entry Points
File:
pyproject.tomlBefore:
After:
Rationale: Package name must be included in the module path now that modules are in a package.
6. Python Version Requirement
File:
pyproject.tomlBefore:
requires-python = ">=3.13"After:
requires-python = ">=3.11"Rationale: Modern type hint syntax (PEP 604, 585) is available in Python 3.10+, and requiring 3.13 unnecessarily limits adoption. Python 3.11 is a good baseline for new projects.
7. Ruff Configuration
File:
pyproject.tomlAdded:
Rationale: Establishes baseline code quality standards. Selected rules focus on:
8. Manual Bug Fixes After Ruff
8.1 Removed Duplicate Tag Definition
File:
src/repomapper/repomap_class.py:39Issue:
Tagwas imported fromutilsbut then redefined locally:Fix: Removed the duplicate definition. The import from
utilsis sufficient.8.2 Removed Unused Variable
File:
src/repomapper/repomap_class.py:286Issue:
input_fileswas declared but never used:Fix: Removed the variable declaration.
8.3 Fixed Undefined Variable Reference
File:
src/repomapper/repomap_class.py:344Issue: Code path returning undefined
file_report:Fix: Create proper FileReport:
8.4 Fixed Bare Except Clause
File:
src/repomapper/repomap_class.py:352Issue: Bare
except:catches all exceptions including KeyboardInterrupt:Fix: Use
except Exception:to catch only expected errors:8.5 Removed Unused Important Files Filter
File:
src/repomapper/repomap_class.py:521-523Issue: Variable assigned but never used:
Fix: Removed the variable assignment and import. This appears to be dead code from a previous implementation.
8.6 Removed Unused Imports
Files: Multiple
Removed:
src/repomapper/utils.py:import os(unused)src/repomapper/utils.py:Listfrom typing (unused after modernization)src/repomapper/repomap.py: Multiple unused imports after refactoringsrc/repomapper/repomap_class.py:namedtupleafter removing duplicate Tagsrc/repomapper/repomap_class.py:filter_important_filesafter removing dead codeAutomatic Ruff Fixes (--fix)
Ruff automatically fixed 102 issues across the codebase. These are grouped by category:
Type Hint Modernization (PEP 604 & PEP 585)
Changes: 89 instances across all files
Pattern 1 - Generic types (PEP 585):
Pattern 2 - Optional types (PEP 604):
Pattern 3 - Union types (PEP 604):
Files affected: All
.pyfiles insrc/repomapper/Rationale: Python 3.9+ supports built-in generic types, and Python 3.10+ supports
|union syntax. This is now the standard way to write type hints.Import Organization (isort)
Changes: 13 instances
Pattern:
Rules Applied:
Files affected: All
.pyfiles with importsDeprecated Import Removal
Pattern:
Rationale:
typing.List,typing.Dict, etc. are deprecated in favor of built-in types.Import from collections.abc
Pattern:
Rationale: PEP 585 moved abstract base classes to
collections.abc. For runtime type checking, these should be imported from their proper location.Testing & Verification
Build Verification
Package Contents Verification
$ python -m zipfile -l dist/repomapper-0.1.1-py3-none-any.whl | grep queries repomapper/queries/tree-sitter-language-pack/... repomapper/queries/tree-sitter-languages/...✅ Queries directory properly included
Linting Verification
$ uv run ruff check src/ All checks passed!Functional Testing
✅ Tool generates output correctly
Original Bug Verification
The original issue was:
This is now fixed:
(None, FileReport(...)))Migration Path for Reviewers
To understand this PR, review in this conceptual order:
pyproject.toml, file moves tosrc/)repomap.py:200tuple unpacking)Backwards Compatibility
.venvand rebuildRisk Assessment
Low Risk Changes:
Medium Risk Changes:
Testing Mitigation:
Recommendations
For future PRs of this scope, consider:
This would create 3 smaller, easier-to-review commits.