leforestier / yattag

Python library to generate HTML or XML in a readable, concise and pythonic way.
333 stars 31 forks source link

Install typing backport only for python versions < 3.5 as it cause is… #59

Closed mschmie closed 4 years ago

mschmie commented 4 years ago

…sues e.g. in python 3.7

leforestier commented 4 years ago

Hi mschmie,

you're right in that it makes total sense to install typing only for Python < 3.5 (since it's already available as part of the core library for Python >= 3.5). However, I'd like to understand what issues you are encountering. I'm using the current version of Yattag with Python 3.8 on Arch Linux, and with Python 3.7 on FreeBSD and I've not encountered any problem related to the typing module. I just want to understand what issue you're having before merging.

mschmie commented 4 years ago

The problem has occurred related with AWS lambda. Please merge the request. I can send you the stacktrace of the error, when I am back in office tomorrow, if you like.

leforestier commented 4 years ago

I'm merging as your mod obviously makes sense. I'm still interested in knowing what kind of problem you might have encoutered because of this.

leforestier commented 4 years ago

It's on pypi now, version 1.13.2.

mschmie commented 4 years ago

Thanks for merging the PR, this has solved the Issue. The stacktrace which I got running my lambda, as follows:

[ERROR] AttributeError: type object 'Callable' has no attribute '_abc_registry'
Traceback (most recent call last):
  File "/var/task/serverless_sdk/__init__.py", line 107, in wrapped_handler
    return user_handler(event, context)
  File "/var/task/s_vinpredict.py", line 19, in error_handler
    raise e
  File "/var/task/s_vinpredict.py", line 14, in <module>
    user_handler = serverless_sdk.get_user_handler('handler.lambda_handler')
  File "/var/task/serverless_sdk/__init__.py", line 53, in get_user_handler
    user_module = import_module(user_module_name)
  File "/var/lang/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/task/handler.py", line 10, in <module>
    from vin_predict_model_service.__main__ import RestServer
  File "/tmp/sls-py-req/vin_predict_model_service/__main__.py", line 4, in <module>
    from hgslib.universal_log.universal_log_falcon_middleware import (
  File "/tmp/sls-py-req/hgslib/__init__.py", line 1, in <module>
    from hgslib.log.log_config import LogConfig
  File "/tmp/sls-py-req/hgslib/log/log_config.py", line 5, in <module>
    from typing import Union, cast
  File "/tmp/sls-py-req/typing.py", line 1357, in <module>
    class Callable(extra=collections_abc.Callable, metaclass=CallableMeta):
  File "/tmp/sls-py-req/typing.py", line 1005, in __new__
    self._abc_registry = extra._abc_registry
leforestier commented 4 years ago

Thanks for the stacktrace. And thanks for submitting the issue and making a PR with the solution.