首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Pytnon 3.6.5上的注释

问使用Pytnon 3.6.5上的注释
EN

Stack Overflow用户
提问于 2021-03-15 14:44:43
回答 1查看 2.9K关注 0票数 2

我正在做一个项目,在这个项目中,我被要求使用责任链编写一些验证代码。我目前在我的机器上使用python 3.9.2,但是在docker上的项目是3.6.5

这段代码在我的机器上运行得很好,但是它破坏了Docker:

代码语言:javascript
复制
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any, Optional


class Handler(ABC):
    """
    The Handler interface declares a method for building the chain of handlers.
    It also declares a method for executing a request.
    """

    @abstractmethod
    def set_next(self, handler: Handler) -> Handler:
        pass

    @abstractmethod
    def handle(self, request) -> Optional[str]:
        pass

显示的错误如下:

代码语言:javascript
复制
 from __future__ import annotations
django_1    |     ^
django_1    | SyntaxError: future feature annotations is not defined

有没有办法使代码在python3.6.5上工作?

EN

回答 1

Stack Overflow用户

发布于 2022-11-02 17:06:11

我在github上找到了这个答案,我正在重新发布,以防有人像我一样出现在这里。

正如@ForceBru annotations作为__future__的一部分是在Python中引入的,因此您需要手动添加dependency (或者将python版本向上移动,这是我推荐的)。

若要添加依赖项,请执行以下操作:

代码语言:javascript
复制
git clone -b legacy_py3.6 https://github.com/QUVA-Lab/e2cnn.git
cd e2cnn
python setup.py install
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66640159

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档