scrapy / parsel

Parsel lets you extract data from XML/HTML documents using XPath or CSS selectors
BSD 3-Clause "New" or "Revised" License
1.13k stars 144 forks source link

UserWarning message after chances in commit 3b3ec90 #274

Closed TecIntelli closed 1 year ago

TecIntelli commented 1 year ago

Unnecessary UserWarning message after change of default of karg root in class Selector from: def __init__( ... root: Optional[Any] = None, ... ) -> None:

to: def __init__( ... root: Optional[Any] = _NOT_SET, ... ) -> None:

Current scapy version 2.6 called this Selector class as super class with karg root=None as default.

This if statement raises the UserWarning message because it does not accept None like in the past. if root is not _NOT_SET: warnings.warn( "Selector got both text and root, root is being ignored.", stacklevel=2, ) I would suggest to change the condition like: if root not in [_NOT_SET, None]:

This issue cames up with the commit 3b3ec90.

wRAR commented 1 year ago

Differentiating between None and _NOT_SET is intentional as None is a valid result of loading JSON. If your only concern is a warning in Scrapy it will disappear once it's fixed in Scrapy which is planned for the next release.