Closed benoit74 closed 4 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
5d95d59
) 100.00% compared to head (cd25285
) 100.00%.:exclamation: Current head cd25285 differs from pull request most recent head 824504f. Consider uploading reports for the commit 824504f to get more accurate results
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Changes done
Nota: please do not merge, I will rebase/push-force before merge first since another PR has been merged in the mean time.
I don't know ... you are right, but somehow this is the price to pay to have proper typing in the whole class, otherwise we will still rely on get_attr
and mostly untyped values.
Should we give it a try or rollback the change?
By rollbacking the change I mean changing only the method signatures, it is already a step forward.
Yes the method signature is what's most important because that's the public API.
Could you use the getattr
way for the optional stuff in an independent commit so we have a better view at both options?
I pushed one more commit to "rollback" what is necessary to keep the get_attr approach while still enhancing the public API.
I tend to admit I prefer this "middle-ground" approach.
Nota: last push is just a rebase on main last commit.
Fix #109 Fix #112
Rationale
Type hints were too restrictive / incorrect
Changes
Item
**kwargs
, the type specified must be the one of individual param values, not the whole dictionaryUnion[str, bool, bytes]
type hint was replaced byAny
, because the goal of this param is precisely to pass any type which could be further usedFileItem
andURLItem
were modified as well because they were very close toStaticItem
StaticItem
in factadd_item
method quite few years agoconvert_image
src
anddst
can be either aPathlib.Path
or anio.BytesIO
(maybe eventyping.BinaryIO
ortyping.IO[bytes]
, but I did not find a convenient way to test this to confirm that adherence totyping.IO[bytes]
contract is sufficient or if we need something additional fromio.BytesIO
)**params
, the type specified must be the one of individual param values, not the whole dictionary ; based on existing codebase across all scrapers I assumed thatstr
is sufficient.save_image
had to be changed as well to reflect changes made inconvert_image