Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pylint vs epylint for editor usage #3606

Closed
pedroqueiroga opened this issue May 8, 2020 · 7 comments
Closed

pylint vs epylint for editor usage #3606

pedroqueiroga opened this issue May 8, 2020 · 7 comments
Labels
Emacs 💾 Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning Question

Comments

@pedroqueiroga
Copy link

pedroqueiroga commented May 8, 2020

Flycheck currently uses pylint, but there are some caveats and epylint seems to address them. In a recent discussion (flycheck/flycheck#1758), @cpitclaudel raised some questions about the usage of epylint, why isn't it integrated into pylint, for example. The questions are pasted below.

Questions

  • What is the "right way" to run pylint in the following example?
  • Is the algorithm implemented by epylint (which is essentially going up until there are no more init.py files) robust? If so, why isn't it used in pylint itself by default?
  • Is epylint supported, and will it remain so in the future? Does it support all the same options as pylint, including support for reading files from stdin? (see Add support for reading from stdin #2746 and pylint: Add support for standard-input t (requires pylint 2.5) flycheck/flycheck#1546 — I worry about this because file names are handled differently there)
  • What should Flycheck do in general: call epylint directly? Or call pylint directly from a working directory calculated as done by epylint? Or something else? We've been unsure for a while, esp. regarding which directory to run from, so it would be great to get a definitive answer. Additionally, I'm assuming that other editors run into the same issue, but the tool being called epylint suggests that there's something special about Emacs ^^

Example:

├── entry.py
└── pkg
    ├── bar.py
    ├── foo.py
    └── __init__.py

Another question

pylint.epylint, when used with runpy.run_module, returns a globals dictionary from which we might use, for example, the Run function: globals_dictionary['Run'](). This happens because epylint isn't a package. Could it be made into a package, with its own main.py?
Current version requires:

import runpy

epylint = runpy.run_module('pylint.epylint')
epylint['Run']()

If it were a package, with a main.py:

import runpy

runpy.run_module('pylint.epylint')
@twmr
Copy link
Contributor

twmr commented May 27, 2021

One additional comment: epylint currently doesn't support linting the code from stdin, but pylint does.

@Pierre-Sassoulas Pierre-Sassoulas added the Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning label Jul 2, 2022
@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Jul 2, 2022

Is epylint supported, and will it remain so in the future?

We don't have emacs user in the contributors, we don't even know if epylint is used a lot. It seems no one read the doc on emacs at least and very few issues are opened. I can't answer any your questions for example because I never touched this part of the code or used it. So we need someone willing to maintain epylint so it's maintained. Alternatively it feel like we could simply remove it in 3.0 and not a lot would happen (I added the need decision label).

@nickdrozd
Copy link
Collaborator

See b2462c9

@nickdrozd nickdrozd closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2022
@cpitclaudel
Copy link
Contributor

It's good to clarify the status of epylint, but most of the questions in the original OP were not about it, but about the right way to invoke pylint itself; maybe these can still be answered? (Though we've made some educated guesses over the last 2.5 years in Flycheck, so it's a bit less relevant now)

@Pierre-Sassoulas
Copy link
Member

We do have an emacs user in the contributor now (@nickdrozd) it does not mean we can answer the questions without retro-engineering though. @cpitclaudel your educated guess are probably the most reliable source of knowledge we have. In particular if epylint is useful for you please tell us so we revert the decision to remove it from pylint :)

@cpitclaudel
Copy link
Contributor

Thanks @Pierre-Sassoulas ! The questions I wanted help with were these, which I don't think involve epylint:

  • What is the "right way" to run pylint in the following example? (See OP for the actual example)
  • What should Flycheck do in general: call epylint directly? Or call pylint directly from a working directory calculated as done by epylint? Or something else? We've been unsure for a while, esp. regarding which directory to run from, so it would be great to get a definitive answer. Additionally, I'm assuming that other editors run into the same issue, but the tool being called epylint suggests that there's something special about Emacs ^^

The long story short about this question is that we have somewhat elaborate logic in Flycheck to find the working directory to use to call pylint (Flycheck is an emacs frontend for checkers that has support for flycheck among others). We don't use epylint, but we noticed that it has its own logic to do search for the right working directory to call pylint from, and we use roughly the same algorithm (reimplemented).

@Pierre-Sassoulas
Copy link
Member

We implemented a recursive option in pylint to find the file to lint in a directory so I would use that alongside with an appropriate reporter, probably a custom json reporter (or the official one). It seems epylint was done specifically for IDE integration but the knowledge got lost and as maintainers don't know much about epylint the most well tested and maintained entry-point is definitely pylint now.

The idea is definitely that pylint will be launched at the root of the repository but if it's not the root of the repository you'll have to ask the user what it is. We're also going to search for configuration files to make it search up the tree until it hits a configuration file or a .git / .hg directory (#7143) so that might also be the way to get the root directory programmatically ? We did not plan to expose that as an API but we could if it's useful to someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Emacs 💾 Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning Question
Projects
None yet
Development

No branches or pull requests

5 participants