flask-nav icon indicating copy to clipboard operation
flask-nav copied to clipboard

Fix deprecation warning for collections

Open shepherdjay opened this issue 4 years ago • 5 comments

Resolves this error

flask_nav\__init__.py:49: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    class ElementRegistry(collections.MutableMapping):

Edit: Fixes #28

shepherdjay avatar Apr 27 '20 18:04 shepherdjay

The warning is an error in Python 3.10, could someone please merge this and make a new release?

ERROR tests/test_flasknav.py - AttributeError: module 'collections' has no attribute 'MutableMapping'                                                                                                              

sbraz avatar Aug 06 '21 22:08 sbraz

@shepherdjay I just noticed you also need to change the import or the module won't work:

diff --git a/flask_nav/__init__.py b/flask_nav/__init__.py
index 7c25dfa..5826b9e 100644
--- a/flask_nav/__init__.py
+++ b/flask_nav/__init__.py
@@ -1,4 +1,4 @@
-import collections
+import collections.abc
 from importlib import import_module
 import re
 
@@ -46,7 +46,7 @@ class NavbarRenderingError(Exception):
     pass
 
 
-class ElementRegistry(collections.MutableMapping):
+class ElementRegistry(collections.abc.MutableMapping):
     def __init__(self):
         self._elems = {}
 

sbraz avatar Aug 06 '21 23:08 sbraz

@sbraz - Updated - sorry did not see your earlier comment been in the middle of a move.

shepherdjay avatar Oct 09 '21 02:10 shepherdjay

Would it be possible to merge and release a new version? Ran into this issue as well and fixed it in analogous way locally. Would be very nice :).

GarfieldTheFirst avatar Apr 25 '23 20:04 GarfieldTheFirst

Yes, please merge this!

Rachelonline avatar Jun 23 '23 17:06 Rachelonline