397e532bdf73e624790685d7f8b9e6bd58d2dfe8
python3/pylance/Expected no type arguments for class \"Union\".md
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | +VS Code + pylanceで以下のPythonコードを書いているときに、遭遇。 |
|
| 2 | + |
|
| 3 | + |
|
| 4 | +``` |
|
| 5 | +U = Union[int, str] |
|
| 6 | +``` |
|
| 7 | + |
|
| 8 | +``` |
|
| 9 | +Expected no type arguments for class "Union"PylancereportGeneralTypeIssues |
|
| 10 | +``` |
|
| 11 | + |
|
| 12 | +### 解決法 |
|
| 13 | +importが間違っている。`from ctypes import Union`していると思う。 |
|
| 14 | +正しくは、`from typing import Union`。 |
|
| 15 | + |
|
| 16 | +VS CodeでAuto Importさせると、こっちがImportされるっぽい… |
|
| ... | ... | \ No newline at end of file |