You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently to mark a package or module to be available in a certain Python version, it has to be moved to a specially named directory (e.g. stdlib/3.4). This has a few shortcomings:
Module removals can't be expressed (like macpath in 3.8)
Additions of submodules is awkward and usually has to duplicate multiple files
Platform-availability can't be expressed
I suggest to add a marker inside stub files based on the existing sys.version_info/sys.platform checks to mark the unavailability of a module, in addition to the existing path-based system. This could, for example, look like this:
This might prove hard to implement "correctly", i.e. refuse imports of unavailable modules, but an easy workaround is to print a warning when such a construct is encountered while parsing a file and possibly stop parsing the stub at this point.
The text was updated successfully, but these errors were encountered:
Huh, Guido must be psychic. This basically fulfills the use case above, except it can't determine that a module can't be imported at all. But in practice this should not matter. This seems like a feature that would be a good fit for the type stub PEP.
This is mostly moot due to the new typeshed layout, where the VERSIONS file specifies available versions. Only open issue are modules unavailable in some OSes, but that sounds more of a typeshed issue anyway.
Currently to mark a package or module to be available in a certain Python version, it has to be moved to a specially named directory (e.g.
stdlib/3.4
). This has a few shortcomings:macpath
in 3.8)I suggest to add a marker inside stub files based on the existing
sys.version_info
/sys.platform
checks to mark the unavailability of a module, in addition to the existing path-based system. This could, for example, look like this:This might prove hard to implement "correctly", i.e. refuse imports of unavailable modules, but an easy workaround is to print a warning when such a construct is encountered while parsing a file and possibly stop parsing the stub at this point.
The text was updated successfully, but these errors were encountered: