Closed willcroft closed 5 years ago
Interesting new feature. You could try on the command line if using flake8 --stdin-display-name could work here.
Just in a shell. If it works there we can think about how we could make this work in SublimeLinter.
Yup, that seems to do the trick:
cat transformations/transforms.py | /usr/local/miniconda3/envs/flake8/bin/flake8 --format default --stdin-display-name transformations/transforms.py -
(No output returned, as in, the linting is passing. Removing the file exception from my .flake8
config results in linting errors, as expected.)
Well, then you can just tell SublimeLinter to do the same using the args
setting.
Ref http://www.sublimelinter.com/en/stable/linter_settings.html#args and http://www.sublimelinter.com/en/stable/settings.html#settings-expansion
"args": ["--stdin-display-name", "${file_path:stdin}"]
🤞
file_path
holds the absolute path to that file. Hope flake8 is okay with that. :stdin
means: for unsaved, new files default to 'stdin'.
Yup, just found the same thing for myself, thanks! A slight tweak as ${file_path}
seems to hold the directory only? So I added to my settings:
"args": [
"--stdin-display-name=${file}"
]
It provides a full file path, as I didn't see a Sublime variable for a project-relative path, though flake8 seems to be just fine with this. (And thanks for the :stdin
trick, will add that too.)
Sure file it is 🤦
Final working solution, for reference: "args": ["--stdin-display-name", "${file:stdin}"]
. Thanks @kaste!
I now see that we have something similar in the Readme. But we have a def better snippet now with the fallback.
The Readme reads a bit rough as well after the last contributions so I would appreciate a small review PR from a native writer. 😏
@kaste if you’d welcome the contribution, I’d be happy to take a look! Unless you already have someone on the team who would prefer to take this on?
Would love a contribution!
Submitted #114! Hope it's useful!
I'm trying to use the
--per-file-ignores
argument introduced in flake8 3.7.0 through a.flake8
config file.The top-level folder open in Sublime Text is the project with a
.flake8
file at the root. I've confirmed that project-wide settings work as expected, such as:But when it comes to setting per-file exclusions, the setting doesn't seem to propagate to the linter:
Looking at the console output, the file is run through
cat
and piped toflake8
which perhaps means the file path is lost?The environment has
flake8==3.7.8
installed.