Remove flake8 pre-commit hook

Fixes #69500
See the issue for details.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/75385
Approved by: https://github.com/seemethere, https://github.com/malfet
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 0b22e2a..b20ecd3 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1098,8 +1098,7 @@
 
 ## Pre-commit tidy/linting hook
 
-We use clang-tidy and flake8 (installed with flake8-bugbear,
-flake8-comprehensions, flake8-pyi, and others) to perform additional
+We use clang-tidy to perform additional
 formatting and semantic checking of code. We provide a pre-commit git hook for
 performing these checks, before a commit is created:
 
@@ -1107,18 +1106,18 @@
   ln -s ../../tools/git-pre-commit .git/hooks/pre-commit
   ```
 
-You'll need to install an appropriately configured flake8; see
-[Lint as you type](https://github.com/pytorch/pytorch/wiki/Lint-as-you-type)
-for documentation on how to do this.
-
-If you haven't set up the pre-commit hook and have already committed files and
+If you have already committed files and
 CI reports `flake8` errors, you can run the check locally in your PR branch with:
 
   ```bash
   flake8 $(git diff --name-only $(git merge-base --fork-point master))
   ```
 
-fix the code so that no errors are reported when you re-run the above check again,
+You'll need to install an appropriately configured flake8; see
+[Lint as you type](https://github.com/pytorch/pytorch/wiki/Lint-as-you-type)
+for documentation on how to do this.
+
+Fix the code so that no errors are reported when you re-run the above check again,
 and then commit the fix.
 
 ## Building PyTorch with ASAN
diff --git a/tools/git-pre-commit b/tools/git-pre-commit
index 1c4340c..a7b9e45 100755
--- a/tools/git-pre-commit
+++ b/tools/git-pre-commit
@@ -1,9 +1,6 @@
 #!/bin/bash
 set -e
 
-echo "Running pre-commit flake8"
-python3 tools/linter/flake8_hook.py
-
 echo "Running pre-commit clang-tidy"
 git diff HEAD > pr.diff
 python3 -m tools.linter.clang_tidy --diff-file "pr.diff"
diff --git a/tools/linter/flake8_hook.py b/tools/linter/flake8_hook.py
deleted file mode 100755
index b9ebd5b..0000000
--- a/tools/linter/flake8_hook.py
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env python3
-
-import sys
-
-from flake8.main import git  # type: ignore[import]
-
-if __name__ == '__main__':
-    sys.exit(
-        git.hook(
-            strict=True,
-            lazy=git.config_for('lazy'),
-        )
-    )