Skip to content

Commit 1a1d850

Browse files
committedMar 30, 2021
remove vcs integration
1 parent 434c108 commit 1a1d850

File tree

13 files changed

+2
-659
lines changed

13 files changed

+2
-659
lines changed
 

‎docs/source/internal/writing-code.rst

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ accepts as well as what it returns.
5959
filepaths = list(copy_indexed_files_to(tempdir, lazy))
6060
app.initialize(['.'])
6161
app.options.exclude = update_excludes(app.options.exclude, tempdir)
62-
app.options._running_from_vcs = True
6362
app.run_checks(filepaths)
6463
6564
app.report_errors()

‎docs/source/manpage.rst

-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@ All options available as of Flake8 3.1.0::
7070
Enable plugins and extensions that are otherwise
7171
disabled by default
7272
--exit-zero Exit with status code "0" even if there are errors.
73-
--install-hook=INSTALL_HOOK
74-
Install a hook that is run prior to a commit for the
75-
supported version control system.
7673
-j JOBS, --jobs=JOBS Number of subprocesses to use to run checks in
7774
parallel. This is ignored on Windows. The default,
7875
"auto", will auto-detect the number of processors

‎docs/source/user/options.rst

-24
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ Index of Options
7878

7979
- :option:`flake8 --exit-zero`
8080

81-
- :option:`flake8 --install-hook`
82-
8381
- :option:`flake8 --jobs`
8482

8583
- :option:`flake8 --output-file`
@@ -751,28 +749,6 @@ Options and their Descriptions
751749
This **can not** be specified in config files.
752750

753751

754-
.. option:: --install-hook=VERSION_CONTROL_SYSTEM
755-
756-
:ref:`Go back to index <top>`
757-
758-
Install a hook for your version control system that is executed before
759-
or during commit.
760-
761-
The available options are:
762-
763-
- git
764-
- mercurial
765-
766-
Command-line usage:
767-
768-
.. prompt:: bash
769-
770-
flake8 --install-hook=git
771-
flake8 --install-hook=mercurial
772-
773-
This **can not** be specified in config files.
774-
775-
776752
.. option:: --jobs=<n>
777753

778754
:ref:`Go back to index <top>`

‎docs/source/user/using-hooks.rst

-76
Original file line numberDiff line numberDiff line change
@@ -36,83 +36,7 @@ plugins, use the ``additional_dependencies`` setting.
3636
- id: flake8
3737
additional_dependencies: [flake8-docstrings]
3838
39-
40-
Built-in Hook Integration
41-
=========================
42-
43-
.. note::
44-
45-
It is strongly suggested to use |Flake8| via `pre-commit`_ over the
46-
built-in hook mechanisms. ``pre-commit`` smooths out many of the rough
47-
edges of ``git`` and is much more battle-tested than the |Flake8|
48-
hook implementation.
49-
50-
|Flake8| can be integrated into your development workflow in many ways. A
51-
default installation of |Flake8| can install pre-commit hooks for both
52-
`Git`_ and `Mercurial`_. To install a built-in hook, you can use the
53-
:option:`flake8 --install-hook` command-line option. For example, you can
54-
install a git pre-commit hook by running:
55-
56-
.. prompt:: bash
57-
58-
flake8 --install-hook git
59-
60-
This will install the pre-commit hook into ``.git/hooks/``. Alternatively,
61-
you can install the mercurial commit hook by running
62-
63-
.. prompt:: bash
64-
65-
flake8 --install-hook mercurial
66-
67-
68-
Preventing Commits
69-
==================
70-
71-
By default, |Flake8| does not prevent you from creating a commit with these
72-
hooks. Both hooks can be configured to be strict easily.
73-
74-
Both our Git and Mercurial hooks check for the presence of ``flake8.strict``
75-
in each VCS' config. For example, you might configure this like so:
76-
77-
.. prompt:: bash
78-
79-
git config --bool flake8.strict true
80-
hg config flake8.strict true
81-
82-
83-
Checking All Modified Files Currently Tracked
84-
=============================================
85-
86-
.. note::
87-
88-
Mercurial does not have the concept of an index or "stage" as best as I
89-
understand.
90-
91-
|Flake8| aims to make smart choices that keep things fast for users where
92-
possible. As a result, the |Flake8| Git pre-commit will default to only
93-
checking files that have been staged (i.e., added to the index). If, however,
94-
you are keen to be lazy and not independently add files to your git index, you
95-
can set ``flake8.lazy`` to ``true`` (similar to how you would set
96-
``flake8.strict`` above) and this will check all tracked files.
97-
98-
This is to support users who often find themselves doing things like:
99-
100-
.. prompt:: bash
101-
102-
git commit -a
103-
104-
.. note::
105-
106-
If you have files you have not yet added to the index, |Flake8| will not
107-
see these and will not check them for you. You must ``git-add`` them
108-
first.
109-
110-
11139
.. _pre-commit:
11240
https://pre-commit.com/
11341
.. _pre-commit docs:
11442
https://pre-commit.com/#pre-commit-configyaml---hooks
115-
.. _Git:
116-
https://git-scm.com/
117-
.. _Mercurial:
118-
https://www.mercurial-scm.org/

‎src/flake8/checker.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ def make_checkers(self, paths=None):
200200
paths = ["."]
201201

202202
filename_patterns = self.options.filename
203-
running_from_vcs = self.options._running_from_vcs
204203
running_from_diff = self.options.diff
205204

206205
# NOTE(sigmavirus24): Yes this is a little unsightly, but it's our
@@ -218,10 +217,8 @@ def should_create_file_checker(filename, argument):
218217
# the event that the argument and the filename are identical.
219218
# If it was specified explicitly, the user intended for it to be
220219
# checked.
221-
explicitly_provided = (
222-
not running_from_vcs
223-
and not running_from_diff
224-
and (argument == filename)
220+
explicitly_provided = not running_from_diff and (
221+
argument == filename
225222
)
226223
return (
227224
explicitly_provided or matches_filename_patterns

‎src/flake8/exceptions.py

-48
Original file line numberDiff line numberDiff line change
@@ -93,51 +93,3 @@ def __str__(self): # type: () -> str
9393
"name": self.plugin["plugin_name"],
9494
"exc": self.original_exception,
9595
}
96-
97-
98-
class HookInstallationError(Flake8Exception):
99-
"""Parent exception for all hooks errors."""
100-
101-
102-
class GitHookAlreadyExists(HookInstallationError):
103-
"""Exception raised when the git pre-commit hook file already exists."""
104-
105-
def __init__(self, path): # type: (str) -> None
106-
"""Initialize the exception message from the `path`."""
107-
self.path = path
108-
tmpl = (
109-
"The Git pre-commit hook ({0}) already exists. To convince "
110-
"Flake8 to install the hook, please remove the existing "
111-
"hook."
112-
)
113-
super(GitHookAlreadyExists, self).__init__(tmpl.format(self.path))
114-
115-
116-
class MercurialHookAlreadyExists(HookInstallationError):
117-
"""Exception raised when a mercurial hook is already configured."""
118-
119-
hook_name = None # type: str
120-
121-
def __init__(self, path, value): # type: (str, str) -> None
122-
"""Initialize the relevant attributes."""
123-
self.path = path
124-
self.value = value
125-
tmpl = (
126-
'The Mercurial {0} hook already exists with "{1}" in {2}. '
127-
"To convince Flake8 to install the hook, please remove the "
128-
"{0} configuration from the [hooks] section of your hgrc."
129-
)
130-
msg = tmpl.format(self.hook_name, self.value, self.path)
131-
super(MercurialHookAlreadyExists, self).__init__(msg)
132-
133-
134-
class MercurialCommitHookAlreadyExists(MercurialHookAlreadyExists):
135-
"""Exception raised when the hg commit hook is already configured."""
136-
137-
hook_name = "commit"
138-
139-
140-
class MercurialQRefreshHookAlreadyExists(MercurialHookAlreadyExists):
141-
"""Exception raised when the hg commit hook is already configured."""
142-
143-
hook_name = "qrefresh"

‎src/flake8/main/application.py

-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,6 @@ def parse_configuration_and_cli(
191191
if not self.parsed_diff:
192192
self.exit()
193193

194-
self.options._running_from_vcs = False
195-
196194
self.check_plugins.provide_options(
197195
self.option_manager, self.options, self.args
198196
)

‎src/flake8/main/git.py

-262
This file was deleted.

‎src/flake8/main/mercurial.py

-145
This file was deleted.

‎src/flake8/main/options.py

-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from flake8 import defaults
66
from flake8.main import debug
7-
from flake8.main import vcs
87

98

109
def register_preliminary_options(parser):
@@ -322,14 +321,6 @@ def register_default_options(option_manager):
322321
help='Exit with status code "0" even if there are errors.',
323322
)
324323

325-
add_option(
326-
"--install-hook",
327-
action=vcs.InstallAction,
328-
choices=vcs.choices(),
329-
help="Install a hook that is run prior to a commit for the supported "
330-
"version control system.",
331-
)
332-
333324
add_option(
334325
"-j",
335326
"--jobs",

‎src/flake8/main/vcs.py

-48
This file was deleted.

‎src/flake8/plugins/pyflakes.py

-7
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22
# -*- coding: utf-8 -*-
33
from __future__ import absolute_import
44

5-
try:
6-
# The 'demandimport' breaks pyflakes and flake8.plugins.pyflakes
7-
from mercurial import demandimport
8-
except ImportError:
9-
pass
10-
else:
11-
demandimport.disable()
125
import os
136
from typing import List
147

‎tests/unit/test_git.py

-29
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.