
1 deplivesb 2021-09-29 11:24:14 +08:00 这和 typing 有什么关系么?除了标题我没看到任何 typing 而且你这个 文件 a import 文件 b,文件 b import 文件 a 。这个循环引用有什么问题么? |
2 ruanimal 2021-09-29 11:27:25 +08:00 if typing.TYPE_CHECKING:from a import A |
3 plko345 2021-09-29 12:27:06 +08:00 via Android 我也有这个疑问 |
4 BBCCBB 2021-09-29 12:39:35 +08:00 现在简单用字符串.. from a import A class B: def func(self, a: 'A') typing 用字符串包裹. |
5 qs 2021-09-29 14:21:06 +08:00 |
6 qW7bo2FbzbC0 2021-09-29 14:58:24 +08:00 很久之前也遇到这个问题,后面改层级和归属解决了。在 go 里面也也遇到同样的问题 |
7 DaguguJ 2021-09-29 14:58:28 +08:00 from import 会导致,局部 import 就不会导致了。感兴趣看看两者的区别。然后,出现这个问题应该是编码不规范,代码不应该这么写的。 |
8 15399905591 OP @BBCCBB 用字符串的话,pycharm 会报警告,不知道为什么 Unresolved reference 'SpecicalDetailValueObject' Inspection info: This inspection detects names that should resolve but don't. Due to dynamic dispatch and duck typing, this is possible in a limited but useful number of cases. Top-level and class-level items are supported better than instance items. |
9 15399905591 OP @qs 你这个应该是 3.7 的新特性, 我用的 3.6, 用不了 |