-
Notifications
You must be signed in to change notification settings - Fork 1k
Refactor project structure, enhance logic, update configurations, and improve code quality #85
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
Merged
cyclotruc
merged 3 commits into
coderamp-labs:main
from
filipchristiansen:refactor/logic-structure-and-config_v2
Jan 3, 2025
Merged
Refactor project structure, enhance logic, update configurations, and improve code quality #85
cyclotruc
merged 3 commits into
coderamp-labs:main
from
filipchristiansen:refactor/logic-structure-and-config_v2
Jan 3, 2025
Conversation
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
cyclotruc
requested changes
Jan 2, 2025
Member
cyclotruc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… improve code quality Refactoring and Logic Improvements - Refactored the `_scan_directory` function in `src/gitingest/ingest_from_query.py` by extracting loop logic into the new `_process_item` function, and further separating functionality into `_process_symlink` and `_process_file` - Replaced multiple return statements with error raising and catching, introducing custom exceptions (`MaxFilesReachedError`, `MaxFileSizeReachedError`, `AlreadyVisitedError`) in the `_process_item` and `_scan_directory` functions - Enhanced the logic in the `process_query` function in `src/process_query.py` for better flow and maintainability - Improved the logic in `_generate_token_string` in `src/gitingest/ingest_from_query.py` - Refined the `download_ingest` function in `src/routers/download.py` for better clarity and functionality Exception Handling Enhancements - Replaced broad `Exception` handling with specific `OSError` in the `_read_file_content` function in `src/gitingest/ingest_from_query.py` - Refined exception handling throughout the codebase, including removing redundant try-except-raise blocks, e.g., in `clone_repo` function in `src/gitingest/clone.py` - Added custom exceptions to `src/gitingest/exceptions.py`: `MaxFilesReachedError`, `MaxFileSizeReachedError`, and `AlreadyVisitedError` - Included explicit re-raising of exceptions in various functions for improved error propagation Test Suite Refactoring - Cleaned up and reorganized test files: - Moved tests from `src/gitingest/tests/` to `tests/` - Consolidated fixtures from `tests/test_ingest.py` into `tests/conftest.py` - Removed redundant content from `tests/conftest.py` - Migrated configuration from `pytest.ini` to `pyproject.toml`, deleted `pytest.ini`, and updated `.dockerignore` Documentation Improvements - Added `darglint` for enforcing `numpy` docstring style in `.pre-commit-config.yaml` for `src/` files - Updated docstrings throughout the codebase, including adding module docstrings where needed - Updated `README.md`: - Added "GitHub stars" badge - Moved the "Discord" badge to its own line - Replaced occurrences of "Gitingest" with "GitIngest" for consistency and clarity Linting and Code Quality - Integrated `pylint` into `.pre-commit-config.yaml` for both `src/` and `tests/` directories - Created `tests/.pylintrc` for linting configuration specific to test files Code Clean-up - Removed the redundant `src/__init__.py` file Naming Conventions and Code Style - Renamed `logSliderToSize` to `log_slider_to_size` in `src/server_utils.py` for consistency with Python's naming conventions - Added explicit encoding specification in multiple instances of `open` throughout the code
Contributor
Author
|
Error looks to be resolved now. Tested locally. @cyclotruc |
cyclotruc
approved these changes
Jan 3, 2025
FOLKS-Tech
pushed a commit
to FOLKS-Tech/gitingest
that referenced
this pull request
Sep 5, 2025
… improve code quality (coderamp-labs#85) * Refactor project structure, enhance logic, update configurations, and improve code quality Refactoring and Logic Improvements - Refactored the `_scan_directory` function in `src/gitingest/ingest_from_query.py` by extracting loop logic into the new `_process_item` function, and further separating functionality into `_process_symlink` and `_process_file` - Replaced multiple return statements with error raising and catching, introducing custom exceptions (`MaxFilesReachedError`, `MaxFileSizeReachedError`, `AlreadyVisitedError`) in the `_process_item` and `_scan_directory` functions - Enhanced the logic in the `process_query` function in `src/process_query.py` for better flow and maintainability - Improved the logic in `_generate_token_string` in `src/gitingest/ingest_from_query.py` - Refined the `download_ingest` function in `src/routers/download.py` for better clarity and functionality Exception Handling Enhancements - Replaced broad `Exception` handling with specific `OSError` in the `_read_file_content` function in `src/gitingest/ingest_from_query.py` - Refined exception handling throughout the codebase, including removing redundant try-except-raise blocks, e.g., in `clone_repo` function in `src/gitingest/clone.py` - Added custom exceptions to `src/gitingest/exceptions.py`: `MaxFilesReachedError`, `MaxFileSizeReachedError`, and `AlreadyVisitedError` - Included explicit re-raising of exceptions in various functions for improved error propagation Test Suite Refactoring - Cleaned up and reorganized test files: - Moved tests from `src/gitingest/tests/` to `tests/` - Consolidated fixtures from `tests/test_ingest.py` into `tests/conftest.py` - Removed redundant content from `tests/conftest.py` - Migrated configuration from `pytest.ini` to `pyproject.toml`, deleted `pytest.ini`, and updated `.dockerignore` Documentation Improvements - Added `darglint` for enforcing `numpy` docstring style in `.pre-commit-config.yaml` for `src/` files - Updated docstrings throughout the codebase, including adding module docstrings where needed - Updated `README.md`: - Added "GitHub stars" badge - Moved the "Discord" badge to its own line - Replaced occurrences of "Gitingest" with "GitIngest" for consistency and clarity Linting and Code Quality - Integrated `pylint` into `.pre-commit-config.yaml` for both `src/` and `tests/` directories - Created `tests/.pylintrc` for linting configuration specific to test files Code Clean-up - Removed the redundant `src/__init__.py` file Naming Conventions and Code Style - Renamed `logSliderToSize` to `log_slider_to_size` in `src/server_utils.py` for consistency with Python's naming conventions - Added explicit encoding specification in multiple instances of `open` throughout the code
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.

This PR refactors the project structure and enhances code quality by:
Refactoring and Logic Improvements
_scan_directoryfunction insrc/gitingest/ingest_from_query.pyby extracting loop logic into the new_process_itemfunction, and further separating functionality into_process_symlinkand_process_fileMaxFilesReachedError,MaxFileSizeReachedError,AlreadyVisitedError) in the_process_itemand_scan_directoryfunctionsprocess_queryfunction insrc/process_query.pyfor better flow and maintainability_generate_token_stringinsrc/gitingest/ingest_from_query.pydownload_ingestfunction insrc/routers/download.pyfor better clarity and functionalityException Handling Enhancements
Exceptionhandling with specificOSErrorin the_read_file_contentfunction insrc/gitingest/ingest_from_query.pyclone_repofunction insrc/gitingest/clone.pysrc/gitingest/exceptions.py:MaxFilesReachedError,MaxFileSizeReachedError, andAlreadyVisitedErrorTest Suite Refactoring
src/gitingest/tests/totests/tests/test_ingest.pyintotests/conftest.pytests/conftest.pypytest.initopyproject.toml, deletingpytest.ini, and updated.dockerignoreDocumentation Improvements
darglintfor enforcingnumpydocstring style in.pre-commit-config.yamlforsrc/filesREADME.md:Linting and Code Quality
pylintinto.pre-commit-config.yamlfor bothsrc/andtests/directoriestests/.pylintrcfor linting configuration specific to test filesCode Clean-up
src/__init__.pyfileNaming Conventions and Code Style
logSliderToSizetolog_slider_to_sizeinsrc/server_utils.pyfor consistency with Python's naming conventionsopenthroughout the code