Skip to content

Refactor imports and styling#14

Open
danelkay93 wants to merge 3 commits intomasterfrom
refactor-imports-and-styling
Open

Refactor imports and styling#14
danelkay93 wants to merge 3 commits intomasterfrom
refactor-imports-and-styling

Conversation

@danelkay93
Copy link
Copy Markdown
Collaborator

No description provided.

- Moved `symbol.py` to `src/abyssal_tome/symbol.py`.
- Consolidated constants by adding `wild` and `fast` to `src/abyssal_tome/constants.py`.
- Updated `scripts/process_new_format.py` to import from `abyssal_tome.symbol`.
- Restored missing `replace_special_tags` function body in `src/abyssal_tome/app.py`.
- Fixed syntax errors in `scripts/process_new_format.py` (indentation) and `scripts/process_json.py` (docstrings/regex).
- Updated `src/abyssal_tome/app.py` to use `constants` for Flet path/port and handle `clipman.init()` gracefully.
- Fixed `tests/test_process_new_format.py` to work with current codebase (imports, models, enum).
- Applied `ruff format` and `ruff check --fix` (including `UP` rules for type hints).
- Added `scripts/__init__.py` to allow importing scripts in tests.
- Moved `symbol.py` to `src/abyssal_tome/symbol.py`.
- Consolidated constants and regex patterns in `src/abyssal_tome/constants.py`.
- Updated `src/abyssal_tome/app.py` to import constants and patterns from `constants.py`, fixing NameErrors.
- Restored missing `replace_special_tags` function body in `src/abyssal_tome/app.py`.
- Fixed syntax errors in `scripts/process_new_format.py` and `scripts/process_json.py`.
- Updated `scripts/process_new_format.py` to use new import paths and list types.
- Fixed `tests/test_process_new_format.py` to work with current codebase (imports, models).
- Added `scripts/__init__.py` to facilitate testing.
- Applied `ruff format` and `ruff check --fix` (including `UP` rules).
- Removed accidental binary index files.
- Moved `symbol.py` to `src/abyssal_tome/symbol.py`.
- Consolidated constants and regex patterns in `src/abyssal_tome/constants.py`.
- Updated `src/abyssal_tome/app.py` to import constants and patterns from `constants.py`, fixing NameErrors.
- Restored missing `replace_special_tags` function body in `src/abyssal_tome/app.py`.
- Fixed syntax errors in `scripts/process_new_format.py` and `scripts/process_json.py`.
- Updated `scripts/process_new_format.py` to use new import paths and list types.
- Fixed `tests/test_process_new_format.py` to work with current codebase (imports, models).
- Added `scripts/__init__.py` to facilitate testing.
- Applied `ruff format` and `ruff check --fix` (including `UP` rules).
- Removed accidental binary index files.
Copilot AI review requested due to automatic review settings November 29, 2025 12:01
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Nov 29, 2025

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • autoreview

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor-imports-and-styling

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

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 refactors imports and applies consistent code formatting across the codebase. The main changes consolidate constants, remove unused imports, and apply Black-style formatting to improve code readability and maintainability.

Key changes:

  • Centralized TAG_TO_LETTER and regex patterns into constants.py to eliminate duplication
  • Removed unused imports (requests, open_dir, lists, sampled_from)
  • Applied Black-style multi-line formatting to long function signatures and calls
  • Updated test signatures to match new API (added parameters to process_ruling_html calls)

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/test_replace_special_tags.py Updated import path from main to abyssal_tome.app; reformatted assertion
tests/test_process_new_format.py Removed unused hypothesis imports; updated test calls with new parameters; removed obsolete test function
src/abyssal_tome/symbol.py Replaced local TAG_TO_LETTER with import from constants
src/abyssal_tome/model.py Applied multi-line formatting to function signatures
src/abyssal_tome/constants.py Added regex import and centralized TAG_TO_LETTER and pattern constants
src/abyssal_tome/app.py Removed unused imports; moved patterns to constants; added clipman error handling; applied extensive multi-line formatting
scripts/process_new_format.py Updated symbol imports to absolute path; commented out duplicate TAG_TO_LETTER
scripts/process_json.py Fixed docstring formatting; removed duplicate code; improved indentation
scripts/enrich_rulings_ai.py Reordered imports; simplified list conversions using sorted() directly on sets
process_json_to_SQLite.py Added pathlib import; replaced open() with Path.open(); removed blank line

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -74,9 +74,9 @@ def test_replace_special_tags(
spans = replace_special_tags(page, ruling_text)
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

The function replace_special_tags is async (as defined in src/abyssal_tome/app.py:183), but it's being called without await. This test function should be marked as async and use await when calling replace_special_tags, or use asyncio.run() to execute the async function.

Copilot uses AI. Check for mistakes.
Comment on lines +87 to +88
"fast": "j",
"wild": "z",
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

[nitpick] The keys 'fast' and 'wild' are added at the end of TAG_TO_LETTER dictionary, breaking alphabetical ordering. The dictionary was previously ordered with symbols like 'willpower', 'agility', 'combat', etc. in a logical grouping. Consider maintaining consistent ordering by placing these entries with their related groups or in alphabetical order.

Copilot uses AI. Check for mistakes.
combined_codes.discard(source_card_code)
return sorted(list(combined_codes))
return sorted(list(set(existing_related_codes)))
return sorted(combined_codes)
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

[nitpick] The simplified sorted(combined_codes) is correct since combined_codes is already a set. However, for consistency with line 77, consider making it explicit that you're sorting a set: sorted(list(combined_codes)). While not technically necessary, it makes the code more uniform and the intent clearer.

Suggested change
return sorted(combined_codes)
return sorted(list(combined_codes))

Copilot uses AI. Check for mistakes.
Comment thread scripts/process_json.py

Removes formatting artifacts, extracts FAQ references, reformats update timestamps, and determines the entry type (erratum, question/answer, or clarification). Returns a structured dictionary with cleaned content, source metadata, card name, and card code, or None if the ruling is empty or overruled.
"""
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

The docstring is missing its closing triple quotes on a new line. The closing \"\"\" should be on line 91 (after the description), not line 90. Currently, line 90 has the closing quotes immediately after 'overruled.' which is inconsistent with the multi-line docstring format used elsewhere in this file and the codebase.

Copilot uses AI. Check for mistakes.
Comment thread src/abyssal_tome/app.py
"""
def _create_copy_button_lambda(btn_ruling_text, btn_ruling_question, btn_ruling_answer, btn_instance: ft.IconButton):

def _create_copy_button_lambda(
Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

Variable _create_copy_button_lambda is not used.

Copilot uses AI. Check for mistakes.
Comment thread src/abyssal_tome/app.py
Comment on lines +614 to 623
def _create_copy_button_lambda_for_card_view(
btn_ruling_text, btn_ruling_question, btn_ruling_answer, btn_instance: ft.IconButton
):
rules_text_content = (
btn_ruling_text or rf"Q: {btn_ruling_question}\n A: {btn_ruling_answer}"
)
return lambda e: asyncio.create_task(
copy_ruling_to_clipboard(e, rules_text_content, btn_instance)
)

Copy link

Copilot AI Nov 29, 2025

Choose a reason for hiding this comment

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

Variable _create_copy_button_lambda_for_card_view is not used.

Suggested change
def _create_copy_button_lambda_for_card_view(
btn_ruling_text, btn_ruling_question, btn_ruling_answer, btn_instance: ft.IconButton
):
rules_text_content = (
btn_ruling_text or rf"Q: {btn_ruling_question}\n A: {btn_ruling_answer}"
)
return lambda e: asyncio.create_task(
copy_ruling_to_clipboard(e, rules_text_content, btn_instance)
)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/abyssal_tome/app.py
@@ -175,30 +159,94 @@ async def highlight_spans(text_spans: list[ft.TextSpan], search_term: str) -> li
return highlighted_spans
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove await on synchronous highlight_text

highlight_spans awaits highlight_text, but highlight_text is a normal function returning a list, not a coroutine. As soon as a search term triggers update_search_view and calls highlight_spans, Python raises TypeError: object list can't be used in 'await' expression, preventing any search results from rendering. Make highlight_text async or drop the await so searches can complete.

Useful? React with 👍 / 👎.

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.

2 participants