Skip to content

refactor: migrate to hatchling and simplify test setup#9

Merged
simedw merged 3 commits intosimedw:mainfrom
sicksubroutine-archive:refactor/migrate-to-hatchling
Jul 6, 2025
Merged

refactor: migrate to hatchling and simplify test setup#9
simedw merged 3 commits intosimedw:mainfrom
sicksubroutine-archive:refactor/migrate-to-hatchling

Conversation

@sicksubroutine
Copy link
Contributor

@sicksubroutine sicksubroutine commented Jul 6, 2025

This pull request introduces updates to the project's build system, dependencies, and testing structure. The most notable changes include migrating from setuptools to hatchling for the build system, removing the need to modify sys.path in test files, and simplifying patching logic in tests for better readability and maintainability.

The Build system is much faster and all of the sys path manipulation is no longer needed. All tests are still passing.

Build System and Dependency Updates:

  • Migrated from setuptools to hatchling as the build backend in pyproject.toml. This involved updating the requires field under [build-system] and removing tool.setuptools configurations.
  • Added License :: OSI Approved :: MIT License to the classifiers section in pyproject.toml.

Test File Improvements:

  • Removed sys.path modifications from all test files, eliminating the need for manual inclusion of the project directory for testing. This change affects files such as tests/test_config.py, tests/test_content_processing.py, tests/test_llm.py, tests/test_main.py, and tests/test_navigation.py. [1] [2] [3] [4] [5]
  • Simplified patching logic across test files by reducing multiline with patch statements into single-line statements for better readability. Examples include tests/test_content_processing.py and tests/test_llm.py. [1] [2]

Switch from setuptools to hatchling for build system and remove
manual sys.path setup from tests since it's no longer needed.
Copilot AI review requested due to automatic review settings July 6, 2025 21:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the Python build backend to Hatchling, removes ad-hoc sys.path hacks from tests, and streamlines test setup by collapsing multi-line patches and concatenations into single-line expressions.

  • Switched from setuptools to hatchling in pyproject.toml and added basic pytest settings.
  • Stripped out all manual sys.path inserts in test files, relying on pytest’s configuration instead.
  • Refactored test code to use single-line statements for list/tuple definitions, patch contexts, and async loops for readability.

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pyproject.toml Migrated build backend to Hatchling; added pytest.ini options
tests/test_web.py Removed sys.path manipulation; simplified string builds
tests/test_views.py Removed sys.path; collapsed multi-line async for loops
tests/test_ui_integration.py Removed sys.path; combined tuple definitions into one line
tests/test_scroll_management.py Removed sys.path; simplified method call argument layout
tests/test_performance.py Removed sys.path; reordered imports and assertion format
tests/test_navigation.py Removed sys.path; collapsed patch contexts and loops
tests/test_main.py Removed sys.path; reordered imports
tests/test_llm.py Removed sys.path; reordered imports; streamlined assignments
tests/test_content_processing.py Removed sys.path; simplified patch statements
tests/test_config.py Removed sys.path; reordered imports
Comments suppressed due to low confidence (2)

tests/test_views.py:1

  • [nitpick] Consider grouping imports into standard library, third-party, and local sections (with blank lines between) to comply with PEP8 import ordering and improve readability.
from unittest.mock import Mock

pyproject.toml:63

  • Verify that the pytest pythonpath setting under tool.pytest.ini_options is supported without additional plugins; otherwise tests may still fail to locate the src package.
pythonpath = ["src"]

self.mock_content_widget.max_scroll_y = property(
lambda self: exec('raise Exception("Test error")')
)
self.mock_content_widget.max_scroll_y = property(lambda self: exec('raise Exception("Test error")'))
Copy link

Copilot AI Jul 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using exec inside a lambda to raise an exception is hard to read; consider defining a simple property that directly raises for clarity in the test.

Suggested change
self.mock_content_widget.max_scroll_y = property(lambda self: exec('raise Exception("Test error")'))
def raise_exception():
raise Exception("Test error")
self.mock_content_widget.max_scroll_y = property(lambda _: raise_exception())

Copilot uses AI. Check for mistakes.
@simedw
Copy link
Owner

simedw commented Jul 6, 2025

This looks great!

I added a formatting check in the CI, just run uv run ruff format . and it should be all set to merge in!

@sicksubroutine
Copy link
Contributor Author

Done! Also on the other PR I just added :) That's probably all I'll do for this weekend, but I might take a crack at a few other things during breaks at work this week.

@simedw simedw merged commit 3492bca into simedw:main Jul 6, 2025
4 checks passed
@simedw
Copy link
Owner

simedw commented Jul 6, 2025

Amazing, thank you!

@sicksubroutine sicksubroutine deleted the refactor/migrate-to-hatchling branch July 7, 2025 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants