Repository navigation
API: Deprecate p2g module - #8855
Conversation
dschult
left a comment
There was a problem hiding this comment.
This all looks good to me -- import cruft is readable, and not too long. Lets leave it in if only to have a record of what you did.... but also because it will be used until v3.9
:)
| ) | ||
| warnings.filterwarnings( | ||
| "ignore", category=DeprecationWarning, message="The p2g module" | ||
| ) |
There was a problem hiding this comment.
huh, for some reason I thought we raise warnings as errors for our pytest runs in CI. But that isn't true.
Anyway running pytest with --doctest-modules will import pg2 before running the fixture so it shows up in the pytest output.
.pixi/envs/default/lib/python3.13/importlib/__init__.py:88: 10 warnings
/Users/mridulseth/dev/networkx/.pixi/envs/default/lib/python3.13/importlib/__init__.py:88: DeprecationWarning: The p2g module is deprecated and will be removed in v3.9
return _bootstrap._gcd_import(name[level:], package, level)
I guess we should just remove the pg2 file from pytest collection with something like?
collect_ignore = ["readwrite/p2g.py"]
There was a problem hiding this comment.
Yup I noticed that too - and was peeved that the warnings filter wasn't catching it (it makes sense though since it was from doctest itself!) +1 for adding to collect_ignore!
There was a problem hiding this comment.
Just tried locally and unfortunately the collect_ignore strategy doesn't work "/. I'd just as soon remove the tests themselves!
There was a problem hiding this comment.
Oops - it looks like I misdiagnosed the problem. It's not the added tests and the module-cache-munging that causes the problem, but simply the fact that the --doctest-modules flag causes an import of all modules. So - this is the problem we have to fix. It's too bad the warnings filter in conftest doesn't pick this up, but I guess it all depends on order-of-operations.
So - we need a different solution!
There was a problem hiding this comment.
Just tried locally and unfortunately the collect_ignore strategy doesn't work "/. I'd just as soon remove the tests themselves!
Nevermind - collect_ignore works fine - I got confused by the other warnings in the summary. After a rebase (with all the other pytest warnings fixed) I noticed these had disappeared too :)
Remove the \'from\' import test for interesting reasons.
Required to suppress doctest warnings.
Closes #8195
Deprecates the entire
p2gmodule (see linked discussion for motivation) by raising on import. In this case, this works because thep2gmodule is excluded from the__all__hierarchy, so it is not picked up by the lazy load machinery, nor is it pulled in with the top level import.I ended up going down a pretty deep rabbit hole in trying to test that deprecation warning gets raised. The situation is trickier than usual due to import caching. What's here works but is quite involved - if folks wanted I'd be just as happy to leave the deprecated warnings testing out!