SublimeLinter / SublimeLinter-flake8

SublimeLinter plugin for python, using flake8.
MIT License
184 stars 28 forks source link

FR: Please support .flake8 config files #86

Closed ptim closed 6 years ago

ptim commented 6 years ago

Hi... I know that this was changed recently, but I cant see exactly where (somewhere near 4.0.0-rc.3?), and I don't understand why (I'm sure you had a good reason!)

The effect of this is that we now need to maintain two separate flake8 config files, one for me in sublime, and another for other contributors using other editors / the CLI (as mentioned tongue in cheek in #58 ).

I hope that the .flake8 config might come back one day, but otherwise... I'm hoping to understand why it disappeared!

Thanks for all your awesome work 👍

Related: #83, #84

kaste commented 6 years ago

This repo itself uses a flake8 file for config, so I really don't know what you mean.

okeeffe commented 6 years ago

I can confirm that as of a recent update my project's .flake8 file is being ignored also. It worked fine before. Have resorted to adjusting the package's settings manually for now.

kaste commented 6 years ago

But why?

Enable SublimeLinter debug mode, look at the console output. Esp. look at the cmd SublimeLinter actually executes and the current working dir cwd.

kaste commented 6 years ago

@ptim @okeeffe not responding doesn't help anyone here.

shooftie commented 6 years ago

For what it's worth, I had my .flake8 file in a folder that was not the top most folder in my project.

project

I had the directory "project" added as a folder in my sublime-project with "repo" excluded such that I had quick access to my .vagrant file. I then added "repo" as a separate folder.

In this configuration sublime linter was not reading my .flake8 file but as soon as I removed "project", which was topmost in the folder structure, my linter started working again.

ptim commented 6 years ago

Very sorry all - missed the replies - I'll take a look at this ASAP

kaste commented 6 years ago

You should try setting "working_dir": "$file_path" or something like that. (The default is $folder.)

shooftie commented 6 years ago

@kaste do you mean in the sublime-linter prefs or in the project file?

kaste commented 6 years ago

@shooftie wherever you want

shooftie commented 6 years ago

@kaste I tried it in my sublime-linter settings and received:

Invalid settings in 'Packages/User/SublimeLinter.sublime-settings':
Additional properties are not allowed ('working_dir' was unexpected)

I can confirm that the setting works when inside my project file e.g.

{
    "SublimeLinter": {
        "working_dir": "$file_path",
        ...
    }
    ...
}
okeeffe commented 6 years ago

Been on holidays, apologies! My problem was also that our .flake8 is not in project root, like @shooftie! Cheers!

kaste commented 6 years ago

Linter settings generally have the form

  "linters": {
     "flake8": {
         "disable": false,
         "python": 3,
         "args": [],
         "excludes": [
             "<untitled>",
             "!${folder}*"
         ],

In project files they go under the key SublimeLinter.

peterboyer commented 6 years ago

I upgraded my linter version and ran into this problem also.

Adding "working_dir": "$file_path" to the linter's settings fixed it for me! Thanks @kaste!

Would be great to either document the fix, or to allow the .flake8 config file to be found in the non-root of the project. Cheers!

kaste commented 6 years ago

I don't think that this is a good setting, especially not a good default.

We have to consider unsaved buffers as well. You could set working_dir to ${folder}/repo as well if that's your normal layout. Or instead of changing the working dir you could just point to a config file using args which supports the same variable substitutions. So it is not really clear what the default here should be.

braver commented 6 years ago

Seems the settings work to deal with the cases we covered here. Perhaps SL could be smarter about config files that aren't in ${folder}, so we might need to do something in core for that to happen. Or at least document how stuff works better.