emacs在flych作用下的稳定性

2024-05-16 02:45:35 发布

您现在位置:Python中文网/ 问答频道 /正文

为了让flycheck为Python工作,我已经达到了一个令人满意的.emacs,结果只需要:

(require 'flycheck)
(add-hook 'after-init-hook #'global-flycheck-mode)

现在看一下forwardpython3.6会是什么样子,即使是两行程序

class Foo():
    pass

收到一大堆警告:

Too few public methods (0/2) [too-few-public-methods]
Class has no __init__ method [no-init]
Old-style class defined. [old-style-class]
Missing class docstring [missing-docstring]
Missing module docstring [missing-docstring]

尽管如此,我现在还是坚定地回到了2.7(sudo port select --set python python27)。你知道吗

Emacs让我们习惯于上下文无关。系统上的内容通常无关紧要;如果从一个不变的.emacs开始,就会得到相同的行为。我的系统中还有什么可能会发生变化,从而触发flycheck警告的突然增加?你知道吗


Tags: no警告initstyle系统publichookclass
2条回答

最好设置次要模式挂钩或只添加到编程模式

(添加hook'prog mode hook'flycheck模式)

通过将其设置为global将在每个缓冲区中启用它,即使在文本模式(如不需要的org模式)中也是如此。也可能会减慢速度。:)

好吧,我找到答案了。你知道吗

flycheckchooses(无声地?)flake8,如果找不到它,它将返回pylint(以及随后的pycompile)。你知道吗

问题是符号链接flake8已经消失了。以下是原因/方法。你知道吗

选择python36后返回

~/ > sudo port select  set python python36
~/ > sudo port select  set python python27

选择pip36后返回

~/ > sudo port select  set pip pip36
~/ > sudo port select  set pip pip27

符号链接/opt/local/bin/flake8消失。只剩下8-2.7片了。你知道吗

> ls -l /opt/local/bin/flake8*
lrwxr-xr-x  1 root  admin  70 20 Mar 16:35 /opt/local/bin/flake8-2.7 -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/flake8

当您更新到python3.6但没有flake8-36时,flake8指向nothing(port select被更新,符号链接被删除)。当您降级到Python2.7时,符号链接无法恢复(其中一个,可能是前者,值得警告,可能是MacPorts中的一个小错误)。你知道吗

~/ > sudo port select  list flake8
Available versions for flake8:
    flake8-27
    none (active)

解决方案是在降级时显式地将flake8指向flake8-27。你知道吗

~/ > sudo port select  set flake8 flake8-27
Selecting 'flake8-27' for 'flake8' succeeded. 'flake8-27' is now active.

链接返回,flycheck选择flake8而不是pylint。你知道吗

> ls -l /opt/local/bin/flake8*
lrwxr-xr-x  1 root  admin  25  7 Sep 09:01 /opt/local/bin/flake8 -> /opt/local/bin/flake8-2.7
lrwxr-xr-x  1 root  admin  70 20 Mar 16:35 /opt/local/bin/flake8-2.7 -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/flake8

相关问题 更多 >