Import Hashable from collections.abc#181
Import Hashable from collections.abc#181The-Compiler wants to merge 2 commits intoyaml:masterfrom The-Compiler:collections
Conversation
In Python 3.7, importing ABCs directly from the 'collections' module shows a warning (and in Python 3.8 it will stop working) - see python/cpython@c66f9f8 Since this is only done in lib3/ which is Python 3 only, we can unconditionally import it from collections.abc instead. This fixes the following DeprecationWarning: .../site-packages/yaml/__init__.py:75: in load return loader.get_single_data() .../site-packages/yaml/constructor.py:37: in get_single_data return self.construct_document(node) .../site-packages/yaml/constructor.py:46: in construct_document for dummy in generator: .../site-packages/yaml/constructor.py:398: in construct_yaml_map value = self.construct_mapping(node) .../site-packages/yaml/constructor.py:204: in construct_mapping return super().construct_mapping(node, deep=deep) .../site-packages/yaml/constructor.py:126: in construct_mapping if not isinstance(key, collections.Hashable): _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ name = 'Hashable' def __getattr__(name): # For backwards compatibility, continue to make the collections ABCs # through Python 3.6 available through the collections module. # Note, no new collections ABCs were added in Python 3.7 if name in _collections_abc.__all__: obj = getattr(_collections_abc, name) import warnings warnings.warn("Using or importing the ABCs from 'collections' instead " "of from 'collections.abc' is deprecated, " "and in 3.8 it will stop working", > DeprecationWarning, stacklevel=2) E DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
|
This is included in #172 |
|
Please can this be merged/released? :-) |
|
This request has been merged into the |
|
merged in 9959328 |
|
@perlpunk why don't you use normal merges visible to everyone? |
|
@webknjaz Several reasons. These PRs were applied by us to the release branch instead of master, and we (@ingydotnet and me) are usually not using the web, but do most things from commandline. Our preferences on how to merge (rebase, squash, marge commits) are different, and we try to make this better in the future. |
|
@perlpunk yeah, but no one sees this then. Visibility matters. I mostly use CLI too, it's great. I'm just advocating for better interlinking. Also, if you use There's a few possible improvements I can suggest:
|
In Python 3.7, importing ABCs directly from the
collectionsmodule shows awarning (and in Python 3.8 it will stop working) - see
python/cpython@c66f9f8
Since this is only done in
lib3/which is Python 3 only, we can unconditionallyimport it from
collections.abcinstead.This fixes the following
DeprecationWarning: