Skip to content

Remove cruft #38

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

Merged
merged 1 commit into from
Jun 12, 2016
Merged

Remove cruft #38

merged 1 commit into from
Jun 12, 2016

Conversation

kaste
Copy link
Contributor

@kaste kaste commented May 10, 2016

Fixes #34, fixes #36

@@ -56,83 +54,11 @@ class Flake8(PythonLinter):
'--max-line-length=': None,
'--max-complexity=': -1,
'--jobs=': '1',
'--show-code=': False
'show-code': False,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's essentially the thing to fix #35. Double '--' means that this is an argument for flake8, but we want it to be an internal argument for the linter.

@kaste
Copy link
Contributor Author

kaste commented May 10, 2016

Well, can you make the linter happy?

@kaste
Copy link
Contributor Author

kaste commented May 10, 2016

image

🎆

@Gr1N
Copy link

Gr1N commented May 10, 2016

Really nice patch! So fix build and merge to master :)

@kaste
Copy link
Contributor Author

kaste commented May 10, 2016

Ok, what's going on here with travis? @groteworld

@jacobsvante
Copy link

Yippie! Can't wait for a new release with this! 🎊 🍻 🎉



class Flake8(PythonLinter):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only line causing the travis failure:

The command "flake8 . --max-line-length=120" exited with 1.
$ pep257 . --ignore=D202
./linter.py:16 in public class `Flake8`:
        D211: No blank lines allowed before class docstring (found 1)

Can you remove this so the build passes? I'd love to see this merged 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually either get a D211: No blank lines allowed before class docstring (found 1) https://travis-ci.org/SublimeLinter/SublimeLinter-flake8/builds/129267208 or a D203: 1 blank line required before class docstring (found 0) https://travis-ci.org/SublimeLinter/SublimeLinter-flake8/builds/129247772

@kaste
Copy link
Contributor Author

kaste commented May 14, 2016

Ah, referring to PyCQA/pydocstyle#141 we loose the default ignore D203 as soon as we pass our own ignore info to pep257.

@kaste kaste force-pushed the patch-1 branch 2 times, most recently from 53fa4ac to a33474c Compare May 14, 2016 11:29
@@ -148,35 +74,17 @@ def split_match(self, match):
if near:
col = None

if self.show_code:
if self.get_view_settings().get('show-code'):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_view_settings should be enough

@kaste
Copy link
Contributor Author

kaste commented May 14, 2016

Okay, we're green. 🙌

@jacobsvante
Copy link

😀

@FichteFoll
Copy link

FichteFoll commented May 25, 2016

Again, referring to PyCQA/pydocstyle#141, you should be using the add-ignore option, which SublimeLinter-pydocstyle (name change) now properly supports:
SublimeLinter/SublimeLinter-pydocstyle#11 (SublimeLinter/SublimeLinter-pydocstyle@b17b4cd and SublimeLinter/SublimeLinter-pydocstyle@6329c42).

Edit: Actually, this has already been changed upstream an is the cause for the merge conflict.

Anyway, please merge this. I'm struck by #33 too and implemented the changes manually in an override package for now.

* Never use builtin python 3.3 for linting Fixes SublimeLinter#33
* Make `show-code` actually work Fixes SublimeLinter#35
* Add option `executable` so you can point explicitly to a flake8 installation in case SL's which isn't smart enough (which it isn't on Windows)
@kaste
Copy link
Contributor Author

kaste commented May 25, 2016

Rebased!

@kaste
Copy link
Contributor Author

kaste commented May 25, 2016

Does anybody know the/one of the maintainer(s)? B/c from my experience it is either you get a response relatively quickly or never. And after two weeks we're heading towards never.

@Gr1N
Copy link

Gr1N commented May 25, 2016

@groteworld can you help with this pr?

@FichteFoll
Copy link

FichteFoll commented Jun 12, 2016

push

This plugin is unusable for Python 3.5 code without this PR.

@groteworld groteworld merged commit ac40521 into SublimeLinter:master Jun 12, 2016
@EmilStenstrom
Copy link

Great fix! 🎊 Will my local version of SublimeLinter-flake8 be updated automatically or does there have to be a release?

@FichteFoll
Copy link

There already is a release. Package control will update it automatically on the next st restart.

@Gr1N
Copy link

Gr1N commented Jun 13, 2016

Guys, something goes wrong after update.
Sublime console:

SublimeLinter: WARNING: no flake8 version could be extracted from:
Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 7, in <module>
    from flake8.main import main
ImportError: No module named flake8.main```

And my flake8 version and path:

~
➔ flake8 --version
2.5.4 (pep8: 1.7.0, pyflakes: 1.2.3, mccabe: 0.4.0) CPython 3.5.1 on Darwin

~
➔ which flake8
/usr/local/bin/flake8

Any ideas?

@EmilStenstrom
Copy link

I get the same error as @Gr1N, I think the offending row is the debug line just above what was posted:

SublimeLinter: flake8 version query: /usr/local/bin/python /virtualenvs/projectX/bin/flake8 --version 
SublimeLinter: WARNING: no flake8 version could be extracted from:
Traceback (most recent call last):
  File "/virtualenvs/projectX/bin/flake8", line 7, in <module>
    from flake8.main import main
ImportError: No module named flake8.main

Note the prefix "/usr/local/bin/python". Doing the same call in the terminal reproduces it:

~ $ /usr/local/bin/python /virtualenvs/projectX/bin/flake8 --version 
Traceback (most recent call last):
  File "/virtualenvs/projectX/bin/flake8", line 7, in <module>
    from flake8.main import main
ImportError: No module named flake8.main

Removing the python executable works fine:

~ $ /virtualenvs/projectX/bin/flake8 --version 
2.5.4 (pep8: 1.7.0, pyflakes: 1.0.0, mccabe: 0.4.0) CPython 3.4.1 on Darwin

@kaste
Copy link
Contributor Author

kaste commented Jun 13, 2016

Damn it. Works for me.

@kaste
Copy link
Contributor Author

kaste commented Jun 13, 2016

Can you post your configuration. On my system I have python 2.7 and 3.5, mostly everything in virtualenvs. And it just works. Default python is 2.7, and a globally installed flake8.

EDIT: I noticed that the version query always goes to the default python, global flake8 installation, maybe that's not good.

@Gr1N
Copy link

Gr1N commented Jun 13, 2016

I have python 2.7 (default) and 3.5 and I use virtualenvs too, but flake8 installed globally using pip3. /usr/local/bin/python — python 2.7 in my system without flake8. Maybe python executable should be configurable through settings?

More logs:

SublimeLinter: find_posix_python: python3 => /usr/local/bin/python3 
SublimeLinter: find_python: system python = /usr/local/bin/python3 
SublimeLinter: find_python: available version = {'minor': 5, 'major': 3} 
SublimeLinter: find_python: <= ('/usr/local/bin/python3', None, 3, 5) 
SublimeLinter: sys.path for /usr/local/bin/python3:
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python35.zip
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/plat-darwin
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/lib-dynload
/usr/local/lib/python3.5/site-packages

SublimeLinter: annotations activated: <builtin> 
reloading settings Packages/User/SublimeLinter.sublime-settings
SublimeLinter: annotations activated: <builtin> 
Package Control: Skipping automatic upgrade, last run at 2016-06-13 11:26:54, next run at 2016-06-13 12:26:54 or after
SublimeLinter: find_python(version=None, script='flake8', module=None) 
SublimeLinter: find_python: default python = /usr/local/bin/python 
SublimeLinter: find_python: available version = {'minor': 7, 'major': 2} 
SublimeLinter: find_python: 'flake8' path = /usr/local/bin/flake8 
SublimeLinter: find_python: <= ('/usr/local/bin/python', '/usr/local/bin/flake8', 2, 7) 
SublimeLinter: flake8 version query: /usr/local/bin/python /usr/local/bin/flake8 --version 
SublimeLinter: WARNING: no flake8 version could be extracted from:
Traceback (most recent call last):
  File "/usr/local/bin/flake8", line 7, in <module>
    from flake8.main import main
ImportError: No module named flake8.main

@EmilStenstrom
Copy link

I have python 2.7 as default (installed via homebrew) and Python 3.4 in paralell. I have flake installed inside a virtualenv running Python 3.4.

@kaste
Copy link
Contributor Author

kaste commented Jun 13, 2016

You sure have some linter config as well. ;-)

Esp. you could have something in paths and python_paths

@kaste
Copy link
Contributor Author

kaste commented Jun 13, 2016

Could you try

diff --git a/linter.py b/linter.py
index 29bdb0c..d21b5e7 100644
--- a/linter.py
+++ b/linter.py
@@ -19,7 +19,7 @@ class Flake8(PythonLinter):
     """Provides an interface to the flake8 python module/script."""

     syntax = 'python'
-    cmd = ('flake8@python', '*', '-')
+    cmd = ('flake8', '*', '-')
     version_args = '--version'
     version_re = r'^(?P<version>\d+\.\d+\.\d+)'
     version_requirement = '>= 2.2.2'

@EmilStenstrom
Copy link

I'll try, but I've never modified a plugin file before. I'm on Mac OSX. Installed plugin through Package Control. Where can I find the linter.py file?

@FichteFoll
Copy link

Use https://packagecontrol.io/packages/PackageResourceViewer to access and modify a resource file.

@Gr1N
Copy link

Gr1N commented Jun 13, 2016

@kaste your fix works perfect.

SublimeLinter: flake8 version query: /usr/local/bin/flake8 --version 
SublimeLinter: flake8 version: 2.5.4 
SublimeLinter: flake8: (>= 2.2.2) satisfied by 2.5.4 
SublimeLinter: flake8 activated: /usr/local/bin/flake8 

@EmilStenstrom
Copy link

Thanks @FichteFoll, that was easier than I thought.

Modifying the file works great for me too. I guess my case is slightly different since I start sublime from inside a virtualenv where flake8 is installed. Non the less, it works! Thanks.

@kaste
Copy link
Contributor Author

kaste commented Jun 14, 2016

Some more feedback on my hotfix? I remember I had this in the first version of this PR, but I don't know anymore why I decided against it.

@kaste
Copy link
Contributor Author

kaste commented Jun 15, 2016

Follow up #41.

groteworld referenced this pull request Jun 15, 2016
[Hotfix] Completely remove invariant python handling for this plugin
@kaste kaste deleted the patch-1 branch July 18, 2022 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants