Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Lint also Django Python files #17

Closed
michel-m opened this issue Aug 24, 2014 · 11 comments
Closed

Lint also Django Python files #17

michel-m opened this issue Aug 24, 2014 · 11 comments

Comments

@michel-m
Copy link

It would be great to have pylint working in Python Django files too. (Syntax from packages such as atom-django by @zacharytamas.)

@exploide
Copy link

Don't know what advantages an integration with atom-django (or similar packages) would have.

But installing the pylint-django plugin for pylint improves the Django support of atom and linter-pylint significantly.

https://github.com/landscapeio/pylint-django

@yoongkang
Copy link

@exploide, I'm having a bit of trouble getting pylint-django to work with linter-pylint.

Under the executables setting, I added "pylint --load-plugins pylint_django" but it crashes pylint. I can run the command from cli with no issue. Any tips?

@exploide
Copy link

  • Make sure pylint is installed for the version of Python you are using (2 vs 3)
  • Make sure pylint-django is installed for the version of Python you are using (pip2 vs pip3 if you install it via pip)
  • To load the plugin, I placed the following .pylintrc file in my home directory:
[MASTER]

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=pylint_django

This avoids the command line switch mentioned in your comment. Maybe this causes the problem.

  • Make sure the Executable variable of the linter-pylint package points to the correct version of pylint (pylint vs python3-pylint)

@SpainTrain
Copy link
Member

@yoongkang did explode's fix work for you?

Closing as this is an old issue and the pylint-django solution seems reasonable. If there are still Django integration issues, please open an issue.

@exploide
Copy link

Well, the use of pylint-django is okayish. In general it works but I always got import errors like F0401 Unable to import 'myapp.models'. Don't know if this is a linter-pylint or pylint or pylint-django issue.

@SpainTrain
Copy link
Member

I always got import errors

Have you tried with the latest version of linter-pylint? We fixed some import issues, so this may work for you now. pylint itself does indeed have issues with some C modules and modules that dynamically export members, though. If after upgrading you are still having issues, please open a new issue and we'll get it figured out!

@dccarmo
Copy link

dccarmo commented May 12, 2017

I'm having the same issue as @yoongkang. Here's my .pylintrc:

# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=pylint_django

And Pylint/Python version:

pylint --version
pylint 1.7.1,
astroid 1.5.2
Python 3.6.1 (default, Apr  4 2017, 09:40:21)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.38)]

Using linter-pylint version 2.1.0.

And also if I run the command from cli it works (having the plugin loaded on .pylintrc)

@ddaanet
Copy link
Contributor

ddaanet commented May 16, 2017

@dccarmo Do you mean you added options to the executable path setting? If that's the case, a crash is normal, because this is no longer the correct executable path.

But it should not be needed, since you already configure load-plugins correctly in your pylintrc. The problem is probably that pylint does not find your pylintrc. Try setting the pylintrc file name explicitly.

By the way, commenting on a years-old, closed bug, saying that you have the "same problem" is bad form. You are not describing your problem fully and it confuses the conversation.

@dccarmo
Copy link

dccarmo commented May 16, 2017

@ddaanet Sorry if I wasn't clear enough.

I'm adding pylint_django to my .pylintrc load-plugins section. When I do that, linter-pylint crashes upon running. This is my issue.

Now if I try running pylint on the terminal, it runs without any issue, even loading the plugin from .pylintrc. So my guess is there's some issue on linter-pylint that's crashing when loading this plugin.

@ddaanet
Copy link
Contributor

ddaanet commented May 16, 2017

If linter-pylint crashes, it gives some output in the development console. Can you paste it here?

@ddaanet
Copy link
Contributor

ddaanet commented May 16, 2017

Or even better, in a new issue, because, you know, this one is closed...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants