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

DeprecationWarning: typing.re is deprecated #5686

Closed
wRAR opened this issue Oct 20, 2022 · 12 comments · Fixed by #5697
Closed

DeprecationWarning: typing.re is deprecated #5686

wRAR opened this issue Oct 20, 2022 · 12 comments · Fixed by #5697

Comments

@wRAR
Copy link
Member

wRAR commented Oct 20, 2022

tests/test_downloader_handlers.py::HttpProxyTestCase::test_download_with_proxy_https_noconnect
tests/test_downloader_handlers.py::Http11ProxyTestCase::test_download_with_proxy_https_noconnect
tests/test_downloader_handlers_http2.py::Http11ProxyTestCase::test_download_with_proxy_https_noconnect
  /opt/hostedtoolcache/Python/3.11.0-rc.2/x64/lib/python3.11/unittest/case.py:292: DeprecationWarning: typing.re is deprecated, import directly from typing instead. typing.re will be removed in Python 3.12.
    if getattr(v, '__warningregistry__', None):

Happens in 3.11 tests.

@iamkaushal
Copy link
Contributor

I would Iike to take this issue @wRAR

@wRAR
Copy link
Member Author

wRAR commented Oct 20, 2022

Sure, go ahed @iamkaushal

@Laerte
Copy link
Member

Laerte commented Oct 24, 2022

@wRAR This deprecation warning is from unitest library, in this case you suggest to catch this warning and suppress?

@Gallaecio
Copy link
Member

Gallaecio commented Oct 25, 2022

It seems so, calling assertWarnsRegex seems to be the cause. Maybe we need to report the issue upstream, then ignore it during tests, including a comment linking to that upstream issue.

@wRAR
Copy link
Member Author

wRAR commented Oct 25, 2022

@Laerte I assumed it's from Scrapy. I've just looked at the code that produces it and I think it's a non-issue: the code accesses all modules from sys.modules, and typing.re is there because of magic in the typing module. So it looks like nobody actually imports it and nothing will break when the module is removed.

@Gallaecio
Copy link
Member

Shall we silence it then, linking to your comment as the reason?

@wRAR
Copy link
Member Author

wRAR commented Oct 25, 2022

I think so, yeah.

@iamkaushal
Copy link
Contributor

should I fix it like this?

with contextlib.suppress(DeprecationWarning):
    with self.assertWarnsRegex(ScrapyDeprecationWarning,
                            r'Using HTTPS proxies in the noconnect mode is deprecated'):
        return self.download_request(request, Spider('foo')).addCallback(_test)

@Gallaecio
Copy link
Member

Gallaecio commented Oct 25, 2022

I believe

scrapy/pytest.ini

Lines 24 to 26 in f4e2a10

filterwarnings =
ignore:scrapy.downloadermiddlewares.decompression is deprecated
ignore:Module scrapy.utils.reqser is deprecated
is the way to go for this.

@wRAR
Copy link
Member Author

wRAR commented Oct 26, 2022

Not sure if it was there last time but now I also see "typing.io is deprecated, import directly from typing instead" in the 3.11 asyncio test.

@iamkaushal
Copy link
Contributor

@wRAR I am using windows, how can I reproduce this warning?

@wRAR
Copy link
Member Author

wRAR commented Oct 27, 2022

@iamkaushal I think it should be enough to run tests with Python 3.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants