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

Migrate to ruff #215

Merged
merged 7 commits into from
Feb 10, 2025
Merged

Migrate to ruff #215

merged 7 commits into from
Feb 10, 2025

Conversation

wRAR
Copy link
Member

@wRAR wRAR commented Feb 7, 2025

Enabling postponed annotations in tests/test_serialization.py breaks two tests because get_type_hints() probably doesn't resolve locally defined classes correctly in this case. In one test it's called from singledispatch(), and it seems to be a known incompatibility before Python 3.14. In another test it's called from andi, and it may suggest that andi doesn't support some user code that uses postponed annotations in the plan callables (andi has some tests for them, but maybe they don't test everything).

Edit: enabling postponed annotations in files that define attr-classes also leads to similar breakages. It could be possible to fix somewhere, though the actual crash is inside typing.get_type_hints(), but needs to be done separately and won't help older versions.

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 97.56098% with 4 lines in your changes missing coverage. Please review.

Project coverage is 98.65%. Comparing base (793c361) to head (ec14b9c).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
web_poet/testing/pytest.py 82.35% 3 Missing ⚠️
web_poet/page_inputs/http.py 93.75% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #215   +/-   ##
=======================================
  Coverage   98.65%   98.65%           
=======================================
  Files          32       32           
  Lines        1486     1487    +1     
=======================================
+ Hits         1466     1467    +1     
  Misses         20       20           
Files with missing lines Coverage Δ
web_poet/_base.py 100.00% <100.00%> (ø)
web_poet/annotated.py 100.00% <100.00%> (ø)
web_poet/exceptions/__init__.py 100.00% <100.00%> (ø)
web_poet/exceptions/core.py 100.00% <100.00%> (ø)
web_poet/exceptions/http.py 100.00% <100.00%> (ø)
web_poet/fields.py 99.10% <100.00%> (ø)
web_poet/mixins.py 100.00% <100.00%> (ø)
web_poet/overrides.py 100.00% <100.00%> (ø)
web_poet/page_inputs/browser.py 100.00% <100.00%> (ø)
web_poet/page_inputs/client.py 94.93% <100.00%> (ø)
... and 17 more

.pre-commit-config.yaml Outdated Show resolved Hide resolved
@wRAR wRAR changed the title Add pyupgrade. Migrate to ruff Feb 8, 2025
@wRAR wRAR marked this pull request as draft February 8, 2025 08:58
@@ -137,7 +139,7 @@ def __call__(cls, *args, **kwargs):
# deprecated class is in jinja2 template). __module__ attribute is not
# important enough to raise an exception as users may be unable
# to fix inspect.stack() errors.
warn(f"Error detecting parent module: {e!r}")
warn(f"Error detecting parent module: {e!r}", stacklevel=1)
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what's the good level here, so I kept the implicit one.

@@ -7,7 +7,7 @@
from .url import ResponseUrl


class BrowserHtml(SelectableMixin, str):
class BrowserHtml(SelectableMixin, str): # noqa: SLOT000
Copy link
Member Author

Choose a reason for hiding this comment

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

Not 100% sure how it works, but it looks like even if __slots__ is defined here, it has no effect (I assume because the other base class doesn't have it).

@wRAR wRAR marked this pull request as ready for review February 8, 2025 09:32

setup(
name="web-poet",
version="0.18.0",
description="Zyte's Page Object pattern for web scraping",
long_description=long_description,
long_description=Path("README.rst").read_text(),
Copy link
Member

Choose a reason for hiding this comment

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

Not an issue specific to these changes, but this may be a good opportunity to specify the encoding, for cross-platform support (not sure when that would become an issue, but it has hit us in the past precisely in setup.py).

@wRAR wRAR merged commit d8d0c30 into master Feb 10, 2025
19 of 20 checks passed
@wRAR wRAR deleted the pyupgrade branch February 10, 2025 16:44
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