Related
Pytest test discovery is failing. The UI states:
Test discovery error, please check the configuration settings for the tests
The output window states:
Test Discovery failed:
Error: Traceback (most recent call last):
File "C:\Users\mikep\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\run_adapter.py", line 16, in <module>
main(tool, cmd, subargs, toolargs)
File "C:\Users\mikep\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\adapter\__main__.py", line 90, in main
parents, result = run(toolargs, **subargs)
File "C:\Users\mikep\.vscode\extensions\ms-python.python-2019.4.11987\pythonFiles\testing_tools\adapter\pytest.py", line 43, in discover
raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 3)
Here are my settings:
{
"python.pythonPath": ".venv\\Scripts\\python.exe",
"python.testing.pyTestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pyTestEnabled": true
}
I can run pytest from the command line successfully FWIW.
I spent ages trying to decipher this unhelpful error after creating a test that had import errors. Verify that your test suite can actually be executed before doing any deeper troubleshooting.
pytest --collect-only is your friend.
This is not a complete answer as I do not know why this is happening and may not relate to your problem, depending how you have your tests structured.
I resolved this issue by putting an __init__.py file in my tests folder
E.G.:
├───.vscode
│ settings.json
│
├───app
│ myapp.py
│
└───tests
test_myapp.py
__init__.py
this was working a few days ago without this but the python extension was recently updated. I am not sure if this is the intended behavior or a side effect of how discoveries are now being made
https://github.com/Microsoft/vscode-python/blob/master/CHANGELOG.md
Use Python code for discovery of tests when using pytest. (#4795)
I just thought I would add my answer here as this might well affect someone who uses a .env file for their project's environment settings since it is such a common configuration for 12 factor apps.
My example assumes that you're using pipenv for your virtual environment management and that you have a .env file at the project's root directory.
My vscode workspace settings json file looks like below. The crucial line for me here was "python.envFile": "${workspaceFolder}/.env",
{
"python.pythonPath": ".venv/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pycodestyleEnabled": false,
"python.linting.flake8Enabled": false,
"python.linting.pylintPath": ".venv/bin/pylint",
"python.linting.pylintArgs": [
"--load-plugins=pylint_django",
],
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--line-length",
"100"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestPath": ".venv/bin/pytest",
"python.envFile": "${workspaceFolder}/.env",
"python.testing.pytestArgs": [
"--no-cov"
],
}
I hope this saves someone the time I spent figuring this out.
In my case the problem with vscode being unable to discover tests was the coverage module being enabled in the setup.cfg (alternatively this could be a pytest.ini), i.e.
addopts= --cov <path> -ra
which caused the test discovery to fail due to low coverage. The solution was to remove that line from the config file.
Also, as suggested in the documentation:
You can also configure testing manually by setting one and only one of the following settings to true: python.testing.unittestEnabled, python.testing.pytestEnabled, and python.testing.nosetestsEnabled.
In settings.json you can also disable coverage using --no-cov flag:
"python.testing.pytestArgs": ["--no-cov"],
EDIT:
Slightly related - in case of more complex projects it might be also necessary to change the rootdir parameter (inside your settings.json) when running tests with pytest (in case of ModuleNotFoundError):
"python.testing.pytestArgs": [
"--rootdir","${workspaceFolder}/<path-to-directory-with-tests>"
],
Seems like a bug in the latest version of VS Code Python extension. I had the same issue, then I downgraded the Python extension to 2019.3.6558 and then it works again. So we should go to our VS Code extensions list, select the Python extension and "Install another version..." from the setting of that extension.
I hope this works for you too.
I resolved the issue by upgrading pytest to the latest version: 4.4.1 with "pip install --upgrade pytest". I was apparently running an old version 3.4.2
Before begin the tests discovery, check that python.testing.cwd points correctly to your tests dir and your python.testing.pytestEnabled is set to true.
Once those requirements are set correctly, run tests discovery and its output (see OUTPUT window). You should see something like this:
python $HOME/.vscode/extensions/ms-python.python-$VERSION/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir $ROOT_DIR_OF_YOUR_PROJECT -s --cache-clear
Test Discovery failed:
Error: ============================= test session starts ==============================
<SETTINGS RELATED TO YOUR MACHINE, PYTHON VERSION, PYTEST VERSION,...>
collected N items / M errors
...
It's important to highlight here the last line: collected N items / M errors. The following lines will contain info about the tests discovered by pytest. So your tests are discoverable but there are errors related to their correct execution.
The following lines will contain the errors which in most of the cases will be related to an incorrect import.
Check that all your dependencies have been downloaded previously. If you are working with specific versions of dependencies (on therequirements.txt file you have something like your_package == X.Y.Z) be sure that it's the right version that you need to.
If you are having trouble with pytest I was struggling with the discovery test part.
Reading some open issue (other) in vscode I found a workaround using the test-adapter extension
market_place_link
The extention works like a charm. (and solve my discovery problem)
In my case, it was the vscode python extension problem.
I switched the test platform from pytest and switched to it back again, and the tests got discovered.
It seems that when testing is universally enabled for all python projects and it fails to discover tests at the beginning, it fails forever!
Test files need to be named test_*.py or *_test.py for pytest collection to work.
Then run pytest --collect-only at the command line to make sure all of the tests are found. Then magically, the flask icon in VSCode suddenly shows the test files and their tests.
As a noob, I was putting my unit tests inside the module files, since I was following the pattern of unittest, and then running pytest *.py. That doesn't work with pytest, and I didn't find a command line argument override the naming convention.
I searched in the settings for "python" and found this:
Switching to pytest automatically detect my tests:
This error is so frustrating..
In my case the error fixed by modifying the python.pythonPath parameter in settings.json (found inside .vscode folder under project root directory), to the path which I obtained using which python in terminal (e.g. /usr/local/var/pyenv/shims/python)
I use pyenv with python3.9, and my error said previously:
Error: Process returned an error: /Users/"user-name"/.pyenv/shims/python:
line 21: /usr/local/Cellar/pyenv/1.2.23/libexec/pyenv: No such file or
directory
at ChildProcess.
(/Users/"user-name"/.vscode/extensions/littlefoxteam.vscode-python-test-adapter-0.6.8/out/src/processRunner.js:35:36)
at Object.onceWrapper (events.js:422:26) at ChildProcess.emit
(events.js:315:20) at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit
(internal/child_process.js:286:5)
In my case, I had to make sure that I was using the right interpreter where the libraries where installed (I used a virtual environment) but the interpreter was pointing to the globally installed python. After changing the interpreter to that of the virtual environment, it worked.
Looking at https://docs.pytest.org/en/latest/usage.html#possible-exit-codes it seems pytest itself is falling over do to some internal error.
I had this same issue and tracked it down to my pytest.ini file. Removing most of the addopts from that file fixed the issue.
I had this problem and struggle with it for hours. I think that there is a special resolution for every other platform configuration. My platform is:
VSCode: 1.55.0 (Ubuntu)
Pytest: 6.2.3
MS Python extension (ms-python.python 2021.3.680753044)
Python Test Explorer for Visual Studio Code (littlefoxteam.vscode-python-test-adapter - 0.6.7)
The worst thing has that the tool itself does not have a standard output (at least that I know of or could find easily on the internet).
In the end, the problem was
--no-cov
parameters that was not recognized by the VSCode testing explorer tool (that I copied from some page on the internet) and the error was showed by the extension littlefoxteam.vscode-python-test-adapter and it may help you to find where things are broken.
In my case, same problem appeared each time when flake8 linter reported errors. Even one error was enough to fail VS Code test discovery.
So the fix is either disable the linter or fix linter errors.
I use setup described here.
2021-12-22
Please find below the settings I used to get pytest working in VsCode after much frustration. I found many helpful pieces of advice here and elsewhere on the internet, but none were complete enough to spare me a bit of cursing. I hope the following will help someone out. This setup allows me to run testing visually from the test explorer extension and also from the integrated terminal. I am using a src format in my workspace and Conda for environment management. The settings related to the terminal setup keep me from having to manually enable my Conda environment or set the python path. Possibly people who have been using VSCODE for more than two days could add something nice to make this better and/or more complete.
##### Vscode info:
Version: 1.63.2 (Universal)
Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3
Date: 2021-12-15T09:37:28.172Z (1 wk ago)
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 20.6.0
##### Testing Extension:
Python Test Explorer for Visual Studio Code
extension installed, v. 0.7.0
##### Pytest version
pytest 6.2.5
##### Directory Structure:
workspace
.env
./src
__init__.py
code1.py
code2.py
./tests
__init__.py
test_code1.py
test_code2.py
##### .env file (in root, but see the "python.envFile" setting in settings.json)
PYTHONPATH=src
#####. settings.json
{
"workbench.colorTheme": "Visual Studio Dark",
"editor.fontFamily": " monospace, Menlo, Monaco, Courier New",
"python.testing.unittestEnabled": false,
"python.testing.cwd": ".",
"terminal.integrated.inheritEnv": true,
"python.envFile": "${workspaceFolder}/.env",
"python.defaultInterpreterPath":
"~/anaconda3/envs/mycurrentenv/bin/python",
"pythonTestExplorer.testFramework": "pytest",
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"tests"
],
"python.terminal.activateEnvironment": true,
"python.terminal.activateEnvInCurrentTerminal": true,
"terminal.integrated.env.osx": {
"PYTHONPATH": "${workspaceFolder}/src:${env:PYTHONPATH}"
}
}
Here is generic way to get Django tests to run with full vscode support
Configure python tests
Choose unittest
Root Directory
test*.py
Then each test case will need to look like the following:
from django.test import TestCase
class views(TestCase):
#classmethod
def setUpClass(cls):
import django
django.setup()
def test_something(self,):
from user.model import something
...
Any functions you want to import have to be imported inside the test case (like shown). The setUpClass runs before the test class is setup and will setup your django project. Once it's setup you can import functions inside the test methods. If you try to import models/views at the top of your script, it will raise an exception since django isn't setup. If you have any other preinitialization that needs to run for your django project to work, run it inside setUpClass. Pytest might work the same way, I haven't tested it.
There are several causes for this.
The simple answer is, it is not perfect. Furthermore, Python is not native to VS Code; Python extensions may not be playing nice either.
I have observed some mitigating measures, though.
NB VS Code didn't "design" test discovery; that is the job of the testing framework. Make sure you have a basic grasp on how it works.
Troubleshooting
For every "battery" of tests, VS Code will gladly tell you what went wrong, right in the Test view panel. To see this, expand the bar with the name of the project, and hover your mouse over the line that is revealed. Look at the traceback.
In the image above, the error is "No module named src". This is more interesting than it sounds. If I import a file from another file, that import path may not be visible to the test discovery mechanism. It may be running from a different "cwd". The best you can do is try to figure out the topmost path of your project, and either add or remove path qualifiers. Until it works.
Main causes
From time to time, VS Code will lose info on the project test configuration. Use command window (Ctrl + Shift + P) to either:
(re)scan tests
(re)configure test spec for the project <-- important!
restart Python Language Server
Python is supposed to remove the need for the empty __init__.py; it seems VS Code loves those. They should be in each folder that leads to a test folder. Not every folder, but the top-down path.
Depending on what you select as the "root test folder" in the test configuration, it might have different meaning based on what VS Code thinks is the root of your project. That probably goes for any specific folder too.
import. VS Code doesn't like syntax errors. It is possible some syntax errors will not get highlighted in the code.
This (unfortunately) goes for all the imports in your file. But you shouldn't test invalid code anyway, right?
Minor buggy behaviors
Running some other visible test might help refresh the discovery process.
VS Code should automatically (by setting) refresh tests on each Save operation. But it doesn't hurt to refresh it manually.
TLDR
Look at the error items in the test panel
Re-configure project test discovery parameters from time to time
Make sure you don't have syntax errors (visible or not)
Create empty __init__.pys in each folder of your project that leads to the test folder
Clean up your import logic
P.S. The Test view has been extensively worked on and improved much over the course of 1 year. Expect changes in behavior.
When I am running via shell a pylint:
$ pylint decorator.py
No config file found, using default configuration
************* Module decorator
C: 7, 0: Unnecessary parens after 'print' keyword (superfluous-parens)
C: 15, 0: Unnecessary parens after 'print' keyword (superfluous-parens)
C: 1, 0: Missing module docstring (missing-docstring)
C: 4, 0: Missing function docstring (missing-docstring)
C: 6, 4: Missing function docstring (missing-docstring)
C: 14, 0: Missing function docstring (missing-docstring)
However, as it can be seen below, these warning do not come up in VSCode
... despite the fact that some basic checking is indeed performed as it shown in the next picture where I have removed a blank line:
Assuming you have configured Python's Extension correctly and you have Pylint installed,
VSCode's Python Extension will do minimal checking by default if you do not provide a Pylint configuration option.
Simply enter "python.linting.pylintUseMinimalCheckers": false, into your .vscode/settings.json to force this off.
This is how mine looks:
{
"autoDocstring.docstringFormat": "numpy",
"editor.minimap.enabled": false,
"editor.selectionClipboard": false,
"python.pythonPath": "/home/jim/anaconda3/envs/dipoleDisplay",
"window.zoomLevel": 0,
"terminal.integrated.rendererType": "dom",
"python.linting.pylintUseMinimalCheckers": false,
}
I had a similar problem where flake8 worked in VSCode but pylint didn't. Here are all the steps I had to check for pylint to start working:
Your .vscode\settings.json file enables linting by pylint
(this can be hand edited or by running these command palette commands: Python: Enable Linting and Python: Select Linter)
"python.linting.enabled": true
"python.linting.pylintEnabled": true
from the command line (while in virtual environment) confirming that pylint and pylint-django are installed.
pip show pylint
pip show pylint-django
Add a .pylintrc file to your root directory that includes these lines.
[MASTER]
load-plugins=pylint_django
(NOTE: you can replace this pylintrc file with the following line in settings.json.)
"python.linting.pylintArgs": ["--load-plugins", "pylint_django"]
For more info about using pylint in VSCode, see https://code.visualstudio.com/docs/python/linting#_pylint
For more info about the pylintrc file, see https://docs.pylint.org/en/1.6.0/run.html#command-line-options
I'm add json to my vscode project folder settings:
{
...
"pylint.path": [
"/home/username/.local/bin/pylint"
],
"pylint.args": [
"--rcfile=api/.pylintrc"
],
...
}
It working for me. My python files and .pylintrc file placed in ./api/ folder, which is subfolder of my project's root.
I have PyTest setup in vs-code but none of the tests are being found even though running pytest from the command line works fine.
(I'm developing a Django app on Win10 using MiniConda and a Python 3.6.6 virtual env. VS Code is fully updated and I have the Python and Debugger for Chrome extensions installed)
Pytest.ini:
[pytest]
DJANGO_SETTINGS_MODULE = callsign.settings
python_files = tests.py test_*.py *_tests.py
vs-code workspace settings:
{
"folders": [
{
"path": "."
}
],
"settings": {
"python.pythonPath": "C:\\ProgramData\\Miniconda3\\envs\\callsign\\python.exe",
"python.unitTest.unittestEnabled": false,
"python.unitTest.nosetestsEnabled": false,
"python.unitTest.pyTestEnabled": true,
"python.unitTest.pyTestArgs": ["--rootdir=.\\callsign", "--verbose"]
}
}
Finally, the output from the Python Test Log inside VS code:
============================= test session starts =============================
platform win32 -- Python 3.6.6, pytest-4.1.1, py-1.7.0, pluggy-0.8.1
Django settings: callsign.settings (from ini file)
rootdir: c:\Users\benhe\Projects\CallsignCopilot\callsign, inifile: pytest.ini
plugins: django-3.4.5
collected 23 items
<Package c:\Users\benhe\Projects\CallsignCopilot\callsign\transcription>
<Module test_utils.py>
<Function test_n_digits>
<Function test_n_alpha>
<Function test_n_hex>
<Function test_n_digits_in_range>
<Function test_v1_audiofilename>
<Function test_v2_audiofilename>
<Function test_v1_bad_int_filename>
<Function test_v1_bad_non_int_filename>
<Function test_bad_format>
<Function test_no_format>
<Function test_too_many_segments>
<Function test_too_few_segments>
<Function test_good_v2_filename>
<Function test_bad_year_v2_filename>
<Function test_bad_month_v2_filename>
<Function test_bad_day_v2_filename>
<Function test_bad_date_v2_filename>
<Function test_bad_short_serial_v2_filename>
<Function test_bad_long_serial_v2_filename>
<Function test_good_v3_filename>
<Function test_good_lowercase_block_v3_filename>
<Function test_bad_non_alpha_block_v3_filename>
<Function test_real_filenames>
======================== no tests ran in 1.12 seconds =========================
Am I missing any steps to get vs-code to find the tests?
If anyone comes across this post-2020, this issue in the vscode-python repo saved my life. Basically, just do the following:
Uninstall the Python extension
Delete the file that contains the extension from your ~/.vscode folder (mine looked like ms-python.python-[YEAR].[MONTH].[VERSION])
Reinstall the extension
Worked like a charm.
EDIT: I downgraded to Pytest 4.0.1 after reading issue 3911 and Test Discovery now works.
Me too. When I blow away .pytest_cache and rerun Python: Discover Unit Tests, I see that the freshly generated .pytest_cache/v/cache/nodeids contains all the tests, but I still get the dialog complaining about No tests discovered.
Python 3.7.2
macOS 10.13.6
VS Code 1.30.2
Python Extension 2018.12.1
Pytest 4.1.0
.vscode/settings.json:
{
"python.linting.enabled": false,
"python.unitTest.unittestEnabled": false,
"python.unitTest.nosetestsEnabled": false,
"python.unitTest.pyTestEnabled": true,
"python.pythonPath": "venv3/bin/python"
}
Tests are in a top-level subdirectory called test. Running pytest manually works.
Another thing to check, if vscode fails to discover the tests, is to make sure it doesn't do so because of the coverage module being enabled. In my case the test cases were being discovered correctly but the discovery eventually kept failing due to low test coverage, as described here. So first, make sure that the tests could actually be collected by pytest as suggested here:
pytest --collect-only
and then make sure you're not forcing coverage check (e.g. in setup.cfg) with e.g.
addopts= --cov <path> -ra
In September 2021, I was able to get VS code to find the test directory again by downgrading the VS Code Python extension from version 2021.9.1191016588 to version v2021.8.1159798656. To downgrade, right-click the extension and click "Install another version..."
The following steps worked for me (assuming latest PyTest installed in Visual Studio Code):
Make sure there are no errors (bottom left of Visual Studio Code)
In Visual Studio Code from File menu choose: File > Close Folder (i.e. close current project folder) and close Visual Studio Code.
Re-open Visual Studio Code and choose: File > Open Folder (re-open the folder that contains your project/test files).
Choose Testing and should have visibility of tests from here ...
VScode needs to specify python configure:
Open Command Palette by Ctrl + shift + p
and write this >python: configure tests And follow the program directions
Note: You may need (Mostly you will not need) to do this first before following the previous steps
My Python plugin and Test Explorer works just fine.
In my case naming the class without test_.py was the issue. In other words, naming the test file without it starting with "test_", not "tests_", makes it so the explorer does not see the issue. Ex: test_.py works but tests_.py, 12345abcde.py don't work.
An obvious thing that caught me...
The test folder hierarchy needs __init__.py files in each folder.
I refactored my tests introducing an extra folder layer and forgot to add __init__.py files.
Command line didn't complain but vscode showed no tests found
In my case the problem was that I had a syntax error in a source file which caused the pytest discovery to fail. Also, note that you get the traceback from Output (tab) -> Python (dropdown).
If everything here fails and you checked all the basic configurations, try specifying the path to your test folder in your workspace's settings.ini file like so. The three configurations below it are from the majority of other solutions.
"python.testing.pytestArgs": [
"${workspaceFolder}/tests"
],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
I am running pylint on an opencv project and I am getting many pylint errors in VS code about members not being present.
Example code:
import cv2
cv2.imshow(....)
Errors obtained:
However , the code runs correctly without any errors.
Versions : pylint 1.8.1 , astroid 1.6.0
This is from pylint. You can generate a pylint config file in the root of your project with this command:
(I find this to be helpful if you work in a team or on different computers from the same repo)
pylint --generate-rcfile > ~/.pylintrc
At the beginning of the generated .pylintrc file you will see
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=
Add cv2 so you end up with
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=cv2
Save the file.
The lint errors should disappear.
On VScode: CTRL + Shift + P
Choose "Preferences: Open Settings (JSON)"
Add this line into JSON file:
"python.linting.pylintArgs": ["--generate-members"]
Done, it works for me
Note: Make sure you choose "Preferences: Open Settings (JSON)", not "Preferences: Open Default Settings (JSON)"
Setting File would look like
{
"workbench.iconTheme": "vscode-icons",
"python.dataScience.sendSelectionToInteractiveWindow": true,
"kite.showWelcomeNotificationOnStartup": false,
"python.dataScience.askForKernelRestart": false,
"python.dataScience.jupyterServerURI": "local",
"python.pythonPath": "/usr/bin/python3",
"workbench.colorTheme": "Monokai",
"vsicons.dontShowNewVersionMessage": true,
"python.linting.pylintArgs": ["--generate-members"] }
Try import cv2 like this:
from cv2 import cv2
Yes it is because the extension has not been installed.
Set this: extension-pkg-whitelist=cv2 and you're good to go.
However it may not detect the functions or modules implemented in cv2
Here the code snippet for the settings.json file in MS V Code
"python.linting.pylintArgs":["--extension-pkg-whitelist=cv2"]
I didn't have to change anything in the pylint Jason file like the most of the answers here My solution is to change the import statement to the form below
from cv2 import cv2
Eventually, cv2 members can be used!
In VSCode, edit the Settings JSON (Ctrl+Shift+P, > "Preferences: Open Settings JSON)
Then, paste the following into the JSON:
"python.linting.pylintArgs": [
... // prievious arguments
"--generated-members=cv2.*"
]
Don't know why, but other solutions (allowlist, etc) weren't working for me, and I didn't want ot create the .pylintrc file.
I used below config settings in settings.json of vscode and it helped me avoid the unessential flags by pylint, and also got intellisense for cv2 working,
it it doesn't work try uninstalling and deleting cv2 packages from C:\Anaconda3\envs\demo1\Lib\site-packages folder, and reinstalling opencv-python package
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=cv2"
]
}
vim-flake8 seems to be ignoring my project-specific config file. If I run flake8 from the command line in my project root, it works, but when I open vim and try to run flake8 against my files, its not picking up that setting. I know this because its using a default line-length of 79, instead of my project-specific 120.
I read this post: flake8 not picking up config file, but it doesn't seem to help. It mentions a bug fixed over a year ago in the comments.
In my project root, I have a .flake8 file with a [flake8] section.
How does vim-flake8 determine what the project root is and where to look for the config file? Does it just use the directory in which Vim is opened?
I ran into a similar issue today, and I got around it by adding the following to my ~/.vimrc (or actually, my ~/.config/nvim/init.vim) file:
let g:syntastic_python_flake8_config_file='.flake8'
This was based on syntastic's official documentation on language-specific configuration files.
I ran into the same problem today. Flake8 ran fine from the command line, but inside of vim every config file seemed do be ignored by syntastic. Running flake8 inside of vim itself (with :!flake8) picked up the config.
Based on the answer from Tomi I fixed it by adding
let g:syntastic_python_flake8_args='--config=setup.cfg'
to my vim config, which should work if vim is started from the project root. Still a bit hacky but at least the flake8 config stays in a single place.
Had the same problem too on my OSX, and partially solved it. Had the latest versions of syntastic (git clone today) and flake8 3.0.4. Vim 7.4.
flake8 ran fine from command line and picked my global ~/.config/flake8. Vim did not output anything if I had the config file, but worked fine without the flake8 config file.
I partially solved the problem by having the flake8 config not in file system but in my .vimrc:
let g:syntastic_python_flake8_args='--ignore=E203,E231'
but this is not the best solution as the config is not shared.
For the initiated developers, when I enable debugging
let g:syntastic_debug = 1
I get this output:
syntastic: 4.516990: &shell = '/bin/bash', &shellcmdflag = '-c', &shellpipe = '2
>&1| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shellslash = 0, &shellte
mp = 1, &shellxquote = '', &shellxescape = ''
syntastic: 4.517587: UpdateErrors (auto): default checkers
syntastic: 4.517927: CacheErrors: default checkers
syntastic: 4.518502: g:syntastic_aggregate_errors = 0
syntastic: 4.518666: getcwd() = '/Volumes/myproject/src'
syntastic: 4.525418: CacheErrors: Invoking checker: python/flake8
syntastic: 4.526113: SyntasticMake: called with options: {'errorformat': '%E%f:%
l: could not compile,%-Z%p^,%A%f:%l:%c: %t%n %m,%A%f:%l: %t%n %m,%-G%.%#', 'make
prg': 'flake8 main.py', 'env': {'TERM': 'dumb'}}
syntastic: 4.727963: system: command run in 0.201426s
syntastic: 4.729751: getLocList: checker python/flake8 returned 1
syntastic: 4.730094: getLocList: checker python/flake8 run in 0.204568s
I couldn't get g:syntastic_python_flake8_* variations working on my MacOS.
The shortcut that worked for me was to add a symlink to the project base directory:
ln -s /path/to/common/.flake8 .flake8
with this link syntastic is forwarded to the .flake8 in the desired location.