M1ha-Shvn / django-pg-bulk-update

Django manager for performing bulk update operations in PostgreSQL database
BSD 3-Clause "New" or "Revised" License
39 stars 13 forks source link

Typing module don't need for Python 3.8 #67

Closed makarovstas closed 3 years ago

makarovstas commented 3 years ago

Hi! In Python 3.8, I catch error AttributeError: type object 'Callable' has no attribute '_abc_registry' , because some packages import Typing module, which is a standard module.

File "/var/lang/lib/python3.8/asyncio/staggered.py", line 6, in <module>    import typing  
File "/var/task/typing.py", line 1359, in <module>    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):  
File "/var/task/typing.py", line 1007, in __new__    
self._abc_registry = extra._abc_registry
M1ha-Shvn commented 3 years ago

Hi, Stas. Thank you for report. I don't see any calls of this library in your trace. All tests pass correctly on python 3.8. Furthermore, I use it myself without any problems. Can you provide the exact line of this library where you catch a bug and full list of python packages installed in your environment?

makarovstas commented 3 years ago

I run my Django app in AWS lambda, maybe this is the reason, because on the local version I did not catch this problem.

Current solutions for me - run pip uninstall typing after django-pg-bulk-update installation.

Full stack trace from logs:

AttributeError: type object 'Callable' has no attribute '_abc_registry'
Traceback (most recent call last):
  File "/var/task/handler.py", line 602, in lambda_handler
    return LambdaHandler.lambda_handler(event, context)
  File "/var/task/handler.py", line 245, in lambda_handler
    handler = cls()
  File "/var/task/handler.py", line 151, in __init__
    wsgi_app_function = get_django_wsgi(self.settings.DJANGO_SETTINGS)
  File "/var/task/zappa/ext/django_zappa.py", line 9, in get_django_wsgi
    from django.core.wsgi import get_wsgi_application
  File "/var/task/django/core/wsgi.py", line 2, in <module>
    from django.core.handlers.wsgi import WSGIHandler
  File "/var/task/django/core/handlers/wsgi.py", line 8, in <module>
    from django.core.handlers import base
  File "/var/task/django/core/handlers/base.py", line 8, in <module>
    from django.urls import get_resolver, set_urlconf
  File "/var/task/django/urls/__init__.py", line 1, in <module>
    from .base import (
  File "/var/task/django/urls/base.py", line 8, in <module>
    from .exceptions import NoReverseMatch, Resolver404
  File "/var/task/django/urls/exceptions.py", line 1, in <module>
    from django.http import Http404
  File "/var/task/django/http/__init__.py", line 5, in <module>
    from django.http.response import (
  File "/var/task/django/http/response.py", line 15, in <module>
    from django.core.serializers.json import DjangoJSONEncoder
  File "/var/task/django/core/serializers/__init__.py", line 23, in <module>
    from django.core.serializers.base import SerializerDoesNotExist
  File "/var/task/django/core/serializers/base.py", line 7, in <module>
    from django.db import models
  File "/var/task/django/db/models/__init__.py", line 3, in <module>
    from django.db.models.aggregates import *  # NOQA
  File "/var/task/django/db/models/aggregates.py", line 5, in <module>
    from django.db.models.expressions import Case, Func, Star, When
  File "/var/task/django/db/models/expressions.py", line 8, in <module>
    from django.db.models import fields
  File "/var/task/django/db/models/fields/__init__.py", line 11, in <module>
    from django import forms
  File "/var/task/django/forms/__init__.py", line 6, in <module>
    from django.forms.boundfield import *  # NOQA
  File "/var/task/django/forms/boundfield.py", line 4, in <module>
    from django.forms.widgets import Textarea, TextInput
  File "/var/task/django/forms/widgets.py", line 26, in <module>
    from .renderers import get_default_renderer
  File "/var/task/django/forms/renderers.py", line 11, in <module>
    from django.template.backends.jinja2 import Jinja2
  File "/var/task/django/template/backends/jinja2.py", line 1, in <module>
    import jinja2
  File "/var/task/jinja2/__init__.py", line 82, in <module>
    _patch_async()
  File "/var/task/jinja2/__init__.py", line 78, in _patch_async
    from jinja2.asyncsupport import patch_all
  File "/var/task/jinja2/asyncsupport.py", line 13, in <module>
    import asyncio
  File "/var/lang/lib/python3.8/asyncio/__init__.py", line 8, in <module>
    from .base_events import *
  File "/var/lang/lib/python3.8/asyncio/base_events.py", line 45, in <module>
    from . import staggered
  File "/var/lang/lib/python3.8/asyncio/staggered.py", line 6, in <module>
    import typing
  File "/var/task/typing.py", line 1359, in <module>
    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
  File "/var/task/typing.py", line 1007, in __new__
    self._abc_registry = extra._abc_registry

pip freeze:

aiohttp==3.6.2
appdirs==1.4.3
argcomplete==1.11.1
async-timeout==3.0.1
attrs==19.3.0
autopep8==1.5
backoff==1.10.0
boto3==1.12.21
botocore==1.15.21
bson==0.5.8
cached-property==1.5.1
cachetools==3.1.1
certifi==2019.11.28
cfn-flip==1.2.2
chardet==3.0.4
Click==7.1.1
curlify==2.2.1
defusedxml==0.6.0
Django==2.2.16
django-appconf==1.0.4
django-compat==1.0.15
django-cors-headers==3.6.0
django-filter==2.4.0
django-hijack==2.1.10
django-hijack-admin==2.1.10
django-jsoneditor==0.1.6
django-pg-bulk-update==3.4.1
django-rest-framework==0.1.0
django-s3-storage==0.13.4
django-select2==7.4.2
django-silk==4.1.0
django-simple-history==2.12.0
django-templated-mail==1.1.1
djangorestframework==3.12.2
-e git+https://github.com/philipn/django-rest-framework-filters.git@4defa59f4fa018d35ac77bbb6d3e35543dbf4948#egg=djangorestframework_filters
djangorestframework-jwt==1.11.0
djongo==1.3.3
djoser==2.0.5
docutils==0.15.2
durationpy==0.5
facebook-business==8.0.4
fpdf==1.7.2
future==0.18.2
google-auth==1.11.3
google-auth-oauthlib==0.4.1
googleads==23.0.1
gprof2dot==2019.11.30
hjson==3.0.1
httplib2==0.14.0
idna==2.9
idna-ssl==1.1.0
isodate==0.6.0
Jinja2==2.10.3
jmespath==0.9.3
jsonfield==2.0.2
kappa==0.6.0
lambda-packages==0.20.0
lxml==4.4.1
mailchimp3==3.0.14
MarkupSafe==1.1.1
mock==4.0.2
multidict==4.7.6
multidimensional-urlencode==0.0.4
nose==1.3.7
oauth2client==4.1.3
oauthlib==3.1.0
packaging==20.1
phonenumberslite==8.12.15
placebo==0.9.0
psycopg2-binary==2.8.6
pyaes==1.6.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.5.0
Pygments==2.6.1
PyJWT==1.7.1
pymongo==3.10.1
pyparsing==2.4.6
python-dateutil==2.6.1
python-slugify==1.2.4
pytils==0.3
pytz==2019.3
PyYAML==5.1.2
requests==2.24.0
requests-oauthlib==1.3.0
requests-toolbelt==0.9.1
rest-framework-generic-relations==1.2.2
retailcrm==5.1.1
rsa==4.0
s3transfer==0.3.3
sentry-sdk==0.19.5
six==1.14.0
sqlparse==0.2.4
toml==0.10.0
tqdm==4.19.1
troposphere==2.5.2
typing-extensions==3.7.4
Unidecode==1.1.1
url-normalize==1.4.2
urllib3==1.25.8
vk==2.0.2
vk-api==11.9.0
Werkzeug==0.16.0
wsgi-request-logger==0.4.6
xmltodict==0.12.0
yarl==1.3.0
zappa==0.50.0
zeep==3.4.0
pypdf2==1.26.0
M1ha-Shvn commented 3 years ago

Hi. Can you have a try from issue-67 branch? Here is the PR. I removed typing installation for python 3.5+ where it is built in.

makarovstas commented 3 years ago

Hi. Can you have a try from issue-67 branch? Here is the PR. I removed typing installation for python 3.5+ where it is built in.

Everything is fine now, bug is gone. Thanks!

M1ha-Shvn commented 3 years ago

I'll make some more requirements improvements and release in several days.

makarovstas commented 3 years ago

Maybe, it makes sense to specify versions for packages in requirements? To minimize the risks of errors due to external librarys updates

M1ha-Shvn commented 3 years ago

I prefer to minimize dependencies and support all versions. I can't tell what dependencies target system will have. Library exact versions can easily conflict with some other libraries (especially with new pip dependency checker). So, I make restrictions as minimalistic as possible.

M1ha-Shvn commented 3 years ago

Removed six dependency and pytz for python 3.3+. So only two libraries I really require in new python versions are django and psycopg2-binary

M1ha-Shvn commented 3 years ago

Released v3.4.2