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 __init__.py insertion bug #1451

Merged
merged 1 commit into from
Dec 29, 2024

Conversation

brianstrauch
Copy link
Contributor

  • Currently, generate.py tries to insert new from ... import ... statements after the first line (See Generate.py quality of life improvements #1259 and Add noracooks.com #1427 (comment)).
  • It looks like the node.level > 0 condition was added to skip the first item (from __future__ import annotations, which the generator considers to be a valid scraper class), but unfortunately self.last_node = node is still reached. The second time __import() is called, the first line is self.last_node and the new import is added beneath it.
  • This PR moves the node.level > 0 condition up into the parent if statement to avoid self.last_node = node from being called. Luckily, this doesn't impact the elif beneath it.
  • I manually validated that we can insert a new scraper class named "AAA" and "ZZZ"

@hhursev
Copy link
Owner

hhursev commented Dec 29, 2024

Thanks for the PR! I appreciate you validating the change with edge cases like "AAA" and "ZZZ" scrapers.

Happy holidays and thanks again for contributing! 🎄 Merging.

@hhursev hhursev merged commit 1436196 into hhursev:main Dec 29, 2024
18 checks passed
@brianstrauch brianstrauch deleted the brianstrauch-patch-1 branch December 29, 2024 19:15
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