Repository: miketheman/pytest-socket (language: python)

Issue:
Replace pytest-flake8 with a pre-commit hook
At some point, pytest and flake8 stopped working well together. See https://github.com/tholo/pytest-flake8/issues/81 and related links.

This may get worse with [pytest 7](https://github.com/tholo/pytest-flake8/issues/83)

On [this thread](https://github.com/pytest-dev/pytest/issues/9217), see a comment around running flake8 as part of pytest is considered an anti pattern.

I think that the more tooling we try to bake into a given pytest run, the harder it is to split them apart, so instead, let's adopt the `pre-commit` framework for executing any stylistic checks we want prior to a commit - flake8, black, isort, and anything else we want, like editorconfig...

This check would need to also run on CI so that if an author doesn't run it locally, it'll catch anything missing.


Discussion / hints:

Fix patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..e5fc3af
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,17 @@
+# See https://pre-commit.com for more information
+# See https://pre-commit.com/hooks.html for more hooks
+repos:
+-   repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v4.0.1
+    hooks:
+    -   id: check-yaml
+    -   id: check-added-large-files
+-   repo: https://github.com/editorconfig-checker/editorconfig-checker.python
+    rev: '2.4.0'
+    hooks:
+    -   id: editorconfig-checker
+        alias: ec
+-   repo: https://github.com/pycqa/flake8
+    rev: '4.0.1'
+    hooks:
+    -   id: flake8
diff --git a/README.md b/README.md
index 663d34c..1c28a9d 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,7 @@
 [![PyPI current version](https://img.shields.io/pypi/v/pytest-socket.svg)](https://pypi.python.org/pypi/pytest-socket)
 [![Python Support](https://img.shields.io/pypi/pyversions/pytest-socket.svg)](https://pypi.python.org/pypi/pytest-socket)
 [![Tests](https://github.com/miketheman/pytest-socket/workflows/Python%20Tests/badge.svg)](https://github.com/miketheman/pytest-socket/actions?query=workflow%3A%22Python+Tests%22)
+[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/miketheman/pytest-socket/main.svg)](https://results.pre-commit.ci/latest/github/miketheman/pytest-socket/main)
 [![Maintainability](https://api.codeclimate.com/v1/badges/1608a75b1c3a20211992/maintainability)](https://codeclimate.com/github/miketheman/pytest-socket/maintainability)
 [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fmiketheman%2Fpytest-socket?ref=badge_shield)
 
diff --git a/pyproject.toml b/pyproject.toml
index 31e1bbc..840df06 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -38,7 +38,6 @@ pytest = ">=3.6.3"
 pytest = "^6.0"
 pytest-cov = "^2.8.1"
 pytest-httpbin = "^1.0"
-pytest-flake8 = "^1.0.4"
 asynctest = "^0.13.0"
 requests = "^2.26.0"
 starlette = "^0.14.2"


Test patch:
diff --git a/pytest.ini b/pytest.ini
index 05b6086..77135b7 100644
--- a/pytest.ini
+++ b/pytest.ini
@@ -2,4 +2,3 @@
 addopts =
     --cov
     --cov-report=term
-    --flake8