Skip to content
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

Fix last tests #4

Merged
merged 2 commits into from
Apr 29, 2024
Merged

Fix last tests #4

merged 2 commits into from
Apr 29, 2024

Conversation

davidemarcoli
Copy link
Collaborator

@davidemarcoli davidemarcoli commented Apr 29, 2024

Summary by CodeRabbit

  • Refactor
    • Updated the behavior of "source" and "group" handlers to retain parsed data after processing.
    • Simplified the episode number extraction process in episode handling.
    • Enhanced debug output control for cleaner and more relevant logging during development.

Copy link

coderabbitai bot commented Apr 29, 2024

Walkthrough

The recent modifications in the project primarily focus on refining debug outputs and enhancing the efficiency of existing functionalities. The handlers.py file sees an adjustment in handler attributes and a streamlined process for episode number extraction. Meanwhile, parse.py optimizes debug message management by incorporating a conditional flag.

Changes

File Summary
.../handlers.py Adjusted remove attribute from True to False in handler settings and simplified episode number extraction logic.
.../parse.py Removed unnecessary print statements; added conditional debug printing based on the DEBUG_HANDLER flag.

🐰✨
A rabbit hopped through the code,
Tweaking lines where bugs once bode.
No more prints spill on the floor,
Handlers tweaked, less is more.
Hop, skip, a code ballet,
Debug whispers now hold sway.
🌟📜


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 93cbdaf and a1cf71b.
Files selected for processing (2)
  • PTT/handlers.py (3 hunks)
  • PTT/parse.py (3 hunks)
Additional Context Used
Ruff (130)
PTT/handlers.py (86)

1-10: Import block is un-sorted or un-formatted


10-10: add_defaults is too complex (19 > 10)


10-10: Too many statements (300 > 50)


106-106: Single quotes found but double quotes preferred


107-107: Single quotes found but double quotes preferred


109-109: Single quotes found but double quotes preferred


109-109: Single quotes found but double quotes preferred


148-148: Single quotes found but double quotes preferred


149-149: Single quotes found but double quotes preferred


150-150: Single quotes found but double quotes preferred


153-153: Single quotes found but double quotes preferred


153-153: Single quotes found but double quotes preferred


156-156: Single quotes found but double quotes preferred


160-160: Single quotes found but double quotes preferred


160-160: Single quotes found but double quotes preferred


160-160: Single quotes found but double quotes preferred


163-163: Single quotes found but double quotes preferred


167-167: Single quotes found but double quotes preferred


168-168: Single quotes found but double quotes preferred


169-169: Single quotes found but double quotes preferred


225-225: Single quotes found but double quotes preferred


226-226: Single quotes found but double quotes preferred


227-227: Single quotes found but double quotes preferred


229-229: Single quotes found but double quotes preferred


231-231: Single quotes found but double quotes preferred


231-231: Single quotes found but double quotes preferred


231-231: Single quotes found but double quotes preferred


231-231: Single quotes found but double quotes preferred


232-232: Single quotes found but double quotes preferred


233-233: Single quotes found but double quotes preferred


233-233: Single quotes found but double quotes preferred


233-233: Single quotes found but double quotes preferred


234-234: Single quotes found but double quotes preferred


234-234: Single quotes found but double quotes preferred


244-244: Single quotes found but double quotes preferred


244-244: Single quotes found but double quotes preferred


248-248: Single quotes found but double quotes preferred


249-249: Single quotes found but double quotes preferred


250-250: Single quotes found but double quotes preferred


367-367: Single quotes found but double quotes preferred


368-368: Single quotes found but double quotes preferred


369-369: Single quotes found but double quotes preferred


370-374: Use a single if statement instead of nested if statements


370-370: Single quotes found but double quotes preferred


370-370: Single quotes found but double quotes preferred


370-370: Single quotes found but double quotes preferred


370-370: Single quotes found but double quotes preferred


372-372: Single quotes found but double quotes preferred


372-372: Single quotes found but double quotes preferred


372-372: Single quotes found but double quotes preferred


372-372: Single quotes found but double quotes preferred


372-372: Single quotes found but double quotes preferred


374-374: Single quotes found but double quotes preferred


375-375: Single quotes found but double quotes preferred


375-375: Single quotes found but double quotes preferred


375-375: Single quotes found but double quotes preferred


377-377: Single quotes found but double quotes preferred


383-383: Single quotes found but double quotes preferred


384-384: Single quotes found but double quotes preferred


384-384: Single quotes found but double quotes preferred


384-384: Single quotes found but double quotes preferred


384-384: Single quotes found but double quotes preferred


385-385: Single quotes found but double quotes preferred


386-386: Single quotes found but double quotes preferred


393-393: Single quotes found but double quotes preferred


394-394: Single quotes found but double quotes preferred


395-395: Single quotes found but double quotes preferred


395-395: Single quotes found but double quotes preferred


395-395: Single quotes found but double quotes preferred


395-395: Single quotes found but double quotes preferred


395-395: Single quotes found but double quotes preferred


395-395: Single quotes found but double quotes preferred


395-395: Single quotes found but double quotes preferred


395-395: Single quotes found but double quotes preferred


396-396: Single quotes found but double quotes preferred


396-396: Single quotes found but double quotes preferred


396-396: Single quotes found but double quotes preferred


396-396: Single quotes found but double quotes preferred


396-396: Single quotes found but double quotes preferred


399-401: Use a single if statement instead of nested if statements


399-399: Single quotes found but double quotes preferred


399-399: Single quotes found but double quotes preferred


400-400: Single quotes found but double quotes preferred


401-401: Single quotes found but double quotes preferred


402-402: Single quotes found but double quotes preferred


403-403: Single quotes found but double quotes preferred

PTT/parse.py (44)

1-6: Import block is un-sorted or un-formatted


33-33: Single quotes found but double quotes preferred


34-34: Single quotes found but double quotes preferred


35-35: Single quotes found but double quotes preferred


37-37: Single quotes found but double quotes preferred


41-41: print found


42-42: print found


46-46: print found


54-54: Single quotes found but double quotes preferred


59-59: print found


60-60: Single quotes found but double quotes preferred


61-61: Single quotes found but double quotes preferred


66-66: Single quotes found but double quotes preferred


66-66: Single quotes found but double quotes preferred


67-67: Single quotes found but double quotes preferred


69-69: Single quotes found but double quotes preferred


70-70: Single quotes found but double quotes preferred


71-71: Single quotes found but double quotes preferred


71-71: Single quotes found but double quotes preferred


72-72: Single quotes found but double quotes preferred


72-72: Single quotes found but double quotes preferred


100-100: Unnecessary assignment to cleaned_title before return statement


112-112: Do not compare types, use isinstance()


114-114: Do not compare types, use isinstance()


116-116: Do not compare types, use isinstance()


124-124: parse is too complex (13 > 10)


140-140: print found


143-143: print found


144-144: print found


148-148: print found


149-149: print found


152-152: Single quotes found but double quotes preferred


153-153: Single quotes found but double quotes preferred


153-153: Single quotes found but double quotes preferred


154-154: Single quotes found but double quotes preferred


155-155: Single quotes found but double quotes preferred


155-155: Single quotes found but double quotes preferred


156-156: Single quotes found but double quotes preferred


157-157: Single quotes found but double quotes preferred


158-158: Single quotes found but double quotes preferred


158-158: Single quotes found but double quotes preferred


159-159: Single quotes found but double quotes preferred


164-164: print found


165-165: print found

Additional comments not posted (3)
PTT/parse.py (1)

139-152: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [140-165]

Conditional debug printing is correctly implemented. Ensure consistency in the use of quotes for string literals.

-                print(handler.handler_name)
-                print("Title before: " + title)
-                print("Title after: " + title)
-                print(end_of_title)
+                print(handler.handler_name)
+                print("Title before: " + title)
+                print("Title after: " + title)
+                print(end_of_title)
PTT/handlers.py (2)

98-98: Consider verifying the behavior change for the "source" handler.

The change from remove: True to remove: False for the "source" handler with regex pattern for "DivX|XviD" might have implications on how data is processed in subsequent steps. Please ensure that this behavior change is intentional and tested, especially since the comment indicates uncertainty about why the test case fails with the original setting.


139-139: Clarify the intended behavior for the "group" handler.

The change from remove: True to remove: False for the "group" handler regex pattern is noted. Similar to the previous comment, it's important to verify that this change aligns with the intended parsing logic, especially since the comment indicates a discrepancy with the JavaScript implementation.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Out of diff range and nitpick comments (4)
PTT/parse.py (4)

Line range hint 1-6: Consider sorting and formatting the import statements to improve readability and maintainability.


Line range hint 33-37: Consider using double quotes consistently for string literals to align with the coding standards.

-        "skipIfAlreadyFound": True,
-        "skipFromTitle": False,
-        "skipIfFirst": False,
-        "remove": False,
+        'skipIfAlreadyFound': True,
+        'skipFromTitle': False,
+        'skipIfFirst': False,
+        'remove': False,

Line range hint 41-46: Conditional debug printing is well implemented. Consider using double quotes for string literals to maintain consistency.

-            print(f"Regexp Pattern: {reg_exp.pattern}")
-            print(f"Title: {title}")
-            print(f"Match: {match}")
+            print(f"Regexp Pattern: {reg_exp.pattern}")
+            print(f"Title: {title}")
+            print(f"Match: {match}")

Line range hint 124-124: Consider refactoring the parse method to reduce its complexity and improve maintainability.

Comment on lines +244 to +250
matches = regex.search(r'(?<!movie\W*|film\W*|^)(?:[ .]+-[ .]+|[([][ .]*)(\d{1,4})(?:a|b|v\d)?(?:\W|$)(?!movie|film)', beginning_title, regex.IGNORECASE) or regex.search(r'^(?:[([-][ .]?)?(\d{1,4})(?:a|b|v\d)?(?:\W|$)(?!movie|film)', middle_title, regex.IGNORECASE)

if matches:
# Extract episode numbers, remove non-digits and convert to integers
episode_numbers = [int(num) for num in regex.findall(r'\d+', matches.group(1))]
result['episodes'] = episode_numbers
return {'match_index': title.index(matches.group(0))}
Copy link

Choose a reason for hiding this comment

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

Refactor the episode number extraction logic for clarity and efficiency.

The logic within handle_episodes for extracting episode numbers can be simplified and made more efficient. Consider using a single regex pattern or restructuring the logic to avoid redundancy and improve readability.

- matches = regex.search(r'(?<!movie\W*|film\W*|^)(?:[ .]+-[ .]+|[([][ .]*)(\d{1,4})(?:a|b|v\d)?(?:\W|$)(?!movie|film)', beginning_title, regex.IGNORECASE) or regex.search(r'^(?:[([-][ .]?)?(\d{1,4})(?:a|b|v\d)?(?:\W|$)(?!movie|film)', middle_title, regex.IGNORECASE)
+ # Simplified regex pattern (example)
+ matches = regex.search(r'(?<!movie\W*|film\W*)(?:\W|^)(\d{1,4})(?:a|b|v\d)?(?:\W|$)', title, regex.IGNORECASE)

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
matches = regex.search(r'(?<!movie\W*|film\W*|^)(?:[ .]+-[ .]+|[([][ .]*)(\d{1,4})(?:a|b|v\d)?(?:\W|$)(?!movie|film)', beginning_title, regex.IGNORECASE) or regex.search(r'^(?:[([-][ .]?)?(\d{1,4})(?:a|b|v\d)?(?:\W|$)(?!movie|film)', middle_title, regex.IGNORECASE)
if matches:
# Extract episode numbers, remove non-digits and convert to integers
episode_numbers = [int(num) for num in regex.findall(r'\d+', matches.group(1))]
result['episodes'] = episode_numbers
return {'match_index': title.index(matches.group(0))}
# Simplified regex pattern (example)
matches = regex.search(r'(?<!movie\W*|film\W*)(?:\W|^)(\d{1,4})(?:a|b|v\d)?(?:\W|$)', title, regex.IGNORECASE)
if matches:
# Extract episode numbers, remove non-digits and convert to integers
episode_numbers = [int(num) for num in regex.findall(r'\d+', matches.group(1))]
result['episodes'] = episode_numbers
return {'match_index': title.index(matches.group(0))}

Copy link

codecov bot commented Apr 29, 2024

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@davidemarcoli davidemarcoli merged commit 2265598 into main Apr 29, 2024
3 of 4 checks passed
@dreulavelle dreulavelle deleted the bugfix/last-tests branch May 6, 2024 19:32
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.

1 participant