From bb37bc32e3a61fd521b10265292a4848bc83bc3e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
Date: Wed, 6 Nov 2019 21:38:00 +0200
Subject: [PATCH] Always run flake8 through pre-commit, and with doctests
 (#28490)

* Enable flake8 doctests everywhere

* Always run flake8 through pre-commit
---
 .vscode/tasks.json | 2 +-
 script/lazytox.py  | 2 +-
 script/lint        | 2 +-
 setup.cfg          | 1 +
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 151868a1663..1a0bfb16a9b 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -33,7 +33,7 @@
     {
       "label": "Flake8",
       "type": "shell",
-      "command": "flake8 homeassistant tests",
+      "command": "pre-commit run flake8 --all-files",
       "group": {
         "kind": "test",
         "isDefault": true
diff --git a/script/lazytox.py b/script/lazytox.py
index 026d4639a06..ca8a160e7dc 100755
--- a/script/lazytox.py
+++ b/script/lazytox.py
@@ -120,7 +120,7 @@ async def pylint(files):
 
 async def flake8(files):
     """Exec flake8."""
-    _, log = await async_exec("flake8", "--doctests", *files)
+    _, log = await async_exec("pre-commit", "run", "flake8", "--files", *files)
     res = []
     for line in log.splitlines():
         line = line.split(":")
diff --git a/script/lint b/script/lint
index 8ba14d8939e..e4bf74cf602 100755
--- a/script/lint
+++ b/script/lint
@@ -15,7 +15,7 @@ printf "%s\n" $files
 echo "================"
 echo "LINT with flake8"
 echo "================"
-flake8 --doctests $files
+pre-commit run flake8 --files $files
 echo "================"
 echo "LINT with pylint"
 echo "================"
diff --git a/setup.cfg b/setup.cfg
index 6d0e5378b44..bb2b1652ffa 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -21,6 +21,7 @@ norecursedirs = .git testing_config
 
 [flake8]
 exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build
+doctests = True
 # To work with Black
 max-line-length = 88
 # E501: line too long
-- 
GitLab