jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.89k stars 259 forks source link

Possible future problem with elpy-flymake-next-error #1272

Closed tomnor closed 6 years ago

tomnor commented 6 years ago

Hello Elpy!

Running Emacs master I have noticed that I am getting no output in the mini-buffer after C-c C-n (elpy-flymake-next-error). Trying to trace the function call a bit, I see that the function elpy-flymake-error-at-point starts with (when (boundp 'flymake-err-info) .... But then I could not find that variable in the flymake source code. Also when checking out emacs-26, I could not see it. Checking out emacs-25 I can find it, and by loading flymake.el from that branch and re-visit my python file, I get the output back.

So I was wondering if somebody already noticed this or am i just totally confused. If not totally confused there should be some updates for compatibility with emacs-26.

What do you think?

jorgenschaefer commented 6 years ago

Nice catch, thank you. Yep, that should get fixed. (Though I think the "correct" fix is to just switch to flycheck entirely)

tomnor commented 6 years ago

Nice catch, thank you. Yep, that should get fixed. (Though I think the "correct" fix is to just switch to flycheck entirely)

Is that a recommendation to me as a user or a plan for the elpy project? Can I use flycheck as a drop-in replacement already?

jorgenschaefer commented 6 years ago

Both, really. And yes, you can:

(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))

Elpy's key bindings for flymake won't work, but you can use Flycheck's key bindings then.

tomnor commented 6 years ago

OK, thanks, then I know ways around it. I guess I can fiddle with the key bindings as well.

Will be interesting to see how it turns out later.

pbgc commented 6 years ago

@jorgenschaefer As I recently started to use 26.1RC I changed to flycheck (I know the keybindings because I use it in several other modes) using your instructions above. The problem is that I get a lot less syntax checks ... it seems that none from flake8. Am I missing something ? Thanks in advance!

jorgenschaefer commented 6 years ago

I do not know how you configured flycheck and what it uses to check errors. Maybe it found pylint and that's reporting stuff? You could look at the flycheck documentation?

pbgc commented 6 years ago

@jorgenschaefer Sorry, I assumed that elpy had some self configuration for flycheck (like it seemd to have for flymake). I will look at the flycheck documentation and and try to configure flycheck. Thanks for your help!!

PS: Flymake on 26.1 seems a lot better than before (unfortunately it doesn't work with Elpy and with current version of flymake-cursor)

zhangda82 commented 6 years ago

I second the observation by @pbgc . flymake-err-info is removed from flymake in Emacs26.1RC, which caused issues with flymake-cursor. flymake-cursor shows the error/diagnostic message right at the cursor, and it's very convenient. Without it, I need to call "flymake-show-diagnostics-buffer" to see the error messages. Quite annoying.

@jorgenschaefer : can you share how to configure your flycheck for working with elpy? Thanks!

pbgc commented 6 years ago

@zhangda82

I have a virtualenv at ~/Development/emacs_vv3with all that I need for elpy (flake8, jedi, rope, etc...) I already used it with:

(setq elpy-rpc-python-command "~/Development/emacs_vv3/bin/python3")

After changing from flymake to flycheck by the instructions above:


(when (require 'flycheck nil t)
  (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  (add-hook 'elpy-mode-hook 'flycheck-mode))

to configure flycheck I only had to insert BEFORE:

(setq flycheck-python-pycompile-executable "~/Development/emacs_vv3/bin/python3")
(setq flycheck-python-flake8-executable "~/Development/emacs_vv3/bin/python3")

there's also flycheck-python-pylint-executable if you want.

in a python file do: c-c ! v to check if flycheck is well configured.

Some keystrokes like c-c c-n to get next error will not work anymore, you will have to use flycheck equivalent M-g n (next error) and M-g p (previous).

Flycheck documentation is great: http://www.flycheck.org/en/latest/languages.html#python http://www.flycheck.org/en/latest/user/error-interaction.html

EDIT: Something important:

Because of this bug: https://gitlab.com/pycqa/flake8/issues/406 You will have to make sure you have pycodestyle==2.3.1 and not 2.4 ... or flake8 will give an error with flycheck. Looking at the url it seems it's fixed but not yet pushed to pypi.

zhangda82 commented 6 years ago

Thanks for sharing!

Da

On Sat, Apr 21, 2018, 04:55 pbgc notifications@github.com wrote:

@zhangda82 https://github.com/zhangda82

I have a virtualenv at "/Development/emacs_vv3" with all that I need for elpy (flake8, jedi, rope, etc...) I already used it with: (setq elpy-rpc-python-command "/Development/emacs_vv3/bin/python3")

After changing from flymake to flycheck by the instructions above:

(when (require 'flycheck nil t) (setq elpy-modules (delq 'elpy-module-flymake elpy-modules)) (add-hook 'elpy-mode-hook 'flycheck-mode))

to configure flycheck I only had to insert BEFORE:

(setq flycheck-python-pycompile-executable " /Development/emacs_vv3/bin/python3") (setq flycheck-python-flake8-executable " /Development/emacs_vv3/bin/python3")

there's also flycheck-python-pylint-executable if you want.

in a python file do: c-c ! v to check if flycheck is well configured.

Some keystrokes like c-c c-n to get next error will not work anymore, you will have to use flycheck equivalente M-g n (next error) and M-g p (previous).

Flychech documentation is great: http://www.flycheck.org/en/latest/languages.html#python http://www.flycheck.org/en/latest/user/error-interaction.html

The documentation is great

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jorgenschaefer/elpy/issues/1272#issuecomment-383279134, or mute the thread https://github.com/notifications/unsubscribe-auth/AMoAwSt-baay1pVWDLMBKzSED2r-jr9Mks5tqvPvgaJpZM4Rlk-w .

tomnor commented 6 years ago

Psst, there is now a bug reported on the loss of flymake-err-info with a solution maybe.

http://lists.gnu.org/archive/html/bug-gnu-emacs/2018-04/msg00985.html

zhangda82 commented 6 years ago

I reported it and the author suggested some ways to work with the new API. Thanks. Da

On Thu, Apr 26, 2018, 15:04 Tomas Nordin notifications@github.com wrote:

Psst, there is now a bug reported on the loss of flymake-err-info with a solution maybe.

http://lists.gnu.org/archive/html/bug-gnu-emacs/2018-04/msg00985.html

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jorgenschaefer/elpy/issues/1272#issuecomment-384755908, or mute the thread https://github.com/notifications/unsubscribe-auth/AMoAwRM_RDlqSIC3hRrrR0FPDvTbPECXks5tshpNgaJpZM4Rlk-w .

jorgenschaefer commented 6 years ago

Thank you. There's another issue with a suggested fix from the author at #1357, let's discuss things over there :-)