匹配案例 - Spyder无效语法

发布于 2025-02-10 01:35:24 字数 314 浏览 1 评论 0原文

在Windows 10上,我在虚拟环境中使用Spyder 5.3.1和Python 3.10.4。 我知道,使用Python 3.10出现Match语句。

但是,每当我在脚本内使用匹配关键字时,出现以下错误:

Code Analysis
Invalid syntax (pyflakes E)

但是我可以正确运行脚本而不会出现任何问题。 那么这里有什么问题呢?

此外,如果我直接在iPython控制台中尝试,则立即识别Match关键字。

I am using Spyder 5.3.1 and Python 3.10.4 within a virtual environment, on Windows 10.
I know that with Python 3.10 came the match statement.

However, whenever I use the match keyword inside a script, the following error appears:

Code Analysis
Invalid syntax (pyflakes E)

But I can run the script correctly without any problem.
So what can be the issue here?

Moreover, if I try directly in the IPython console, the match keyword is immediately recognized.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酸甜透明夹心 2025-02-17 01:35:25

Spyder并不是一个问题,而是它用于覆盖代码的Pyflakes系统。

匹配是Python 3.10中的新(软)关键字。 pyflakes 2.4.0 目前仅支持Python 3.8。

pyflakes 2.5.0 尚未出现,但会掩盖到Python 3.11,并且应该正确地贴上新的匹配关键字。

It's not so much an issue with Spyder as it is with the Pyflakes system it uses for linting code.

match is a new (soft) keyword in Python 3.10. Pyflakes 2.4.0 only supports up to Python 3.8 currently.

Pyflakes 2.5.0 is not out yet, but will cover up to Python 3.11, and should lint the new match keyword properly.

痴意少年 2025-02-17 01:35:25

“匹配”之后,通过添加此评论来解决“无效的语法错误”

match ... # noqa

由于这仍然是一个问题,请注意,通过在Github上指出 : https://github.com/spyder-com/spyder-ide/spyder/spyder/spyder/sspyder/17436#issuecomment-10598067055

Since this still is an issue, note that there is a workaround to get rid of the "invalid syntax error" by adding this comment after the "match"

match ... # noqa

Was pointed out on Github here: https://github.com/spyder-ide/spyder/issues/17436#issuecomment-1059806705

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文