summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2021-03-14 19:09:43 +0000
committerAnthony Sottile <asottile@umich.edu>2021-03-14 19:09:43 +0000
commit7c96c1e901fed326465316324e2c20bc1d7bc45a (patch)
tree80fe51912a9d61bfb9ac3127aeaaf3eb2699b0cd
parentfd71b8650988d1ac74fd262ed96d11da1966c412 (diff)
parent40aba49d0d0833edf65ee9d3c3a2b511bac6f2dd (diff)
downloadflake8-7c96c1e901fed326465316324e2c20bc1d7bc45a.tar.gz
Merge branch 'pycodestyle_2_7_0' into 'master'
upgrade pycodestyle to 2.7.0 See merge request pycqa/flake8!467
-rw-r--r--docs/source/user/options.rst23
-rw-r--r--setup.cfg2
-rw-r--r--src/flake8/defaults.py1
-rw-r--r--src/flake8/main/options.py9
-rw-r--r--src/flake8/processor.py4
-rw-r--r--tests/integration/test_main.py3
-rw-r--r--tests/unit/conftest.py1
7 files changed, 40 insertions, 3 deletions
diff --git a/docs/source/user/options.rst b/docs/source/user/options.rst
index 5e62453..d2c0edb 100644
--- a/docs/source/user/options.rst
+++ b/docs/source/user/options.rst
@@ -64,6 +64,8 @@ Index of Options
- :option:`flake8 --max-doc-length`
+- :option:`flake8 --indent-size`
+
- :option:`flake8 --select`
- :option:`flake8 --disable-noqa`
@@ -570,6 +572,27 @@ Options and their Descriptions
max-doc-length = 79
+.. option:: --indent-size=<n>
+
+ :ref:`Go back to index <top>`
+
+ Set the number of spaces used for indentation.
+
+ By default, 4.
+
+ Command-line example:
+
+ .. prompt:: bash
+
+ flake8 --indent-size 2 dir/
+
+ This **can** be specified in config files.
+
+ Example config file usage:
+
+ .. code-block:: ini
+
+ indent-size = 2
.. option:: --select=<errors>
diff --git a/setup.cfg b/setup.cfg
index 5046e68..3555655 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -41,7 +41,7 @@ install_requires=
# And in which releases we will update those ranges here:
# http://flake8.pycqa.org/en/latest/internal/releases.html#releasing-flake8
pyflakes >= 2.3.0, < 2.4.0
- pycodestyle >= 2.6.0a1, < 2.7.0
+ pycodestyle >= 2.7.0, < 2.8.0
mccabe >= 0.6.0, < 0.7.0
enum34; python_version<"3.4"
typing; python_version<"3.5"
diff --git a/src/flake8/defaults.py b/src/flake8/defaults.py
index 1d32bd7..d590857 100644
--- a/src/flake8/defaults.py
+++ b/src/flake8/defaults.py
@@ -15,6 +15,7 @@ EXCLUDE = (
IGNORE = ("E121", "E123", "E126", "E226", "E24", "E704", "W503", "W504")
SELECT = ("E", "F", "W", "C90")
MAX_LINE_LENGTH = 79
+INDENT_SIZE = 4
TRUTHY_VALUES = {"true", "1", "t"}
diff --git a/src/flake8/main/options.py b/src/flake8/main/options.py
index a0f066f..0a6ad45 100644
--- a/src/flake8/main/options.py
+++ b/src/flake8/main/options.py
@@ -105,6 +105,7 @@ def register_default_options(option_manager):
- ``--per-file-ignores``
- ``--max-line-length``
- ``--max-doc-length``
+ - ``--indent-size``
- ``--select``
- ``--disable-noqa``
- ``--show-source``
@@ -254,6 +255,14 @@ def register_default_options(option_manager):
help="Maximum allowed doc line length for the entirety of this run. "
"(Default: %(default)s)",
)
+ add_option(
+ "--indent-size",
+ type=int,
+ metavar="n",
+ default=defaults.INDENT_SIZE,
+ parse_from_config=True,
+ help="Number of spaces used for indentation (Default: %default)",
+ )
add_option(
"--select",
diff --git a/src/flake8/processor.py b/src/flake8/processor.py
index b675c99..ad011c3 100644
--- a/src/flake8/processor.py
+++ b/src/flake8/processor.py
@@ -83,6 +83,10 @@ class FileProcessor(object):
self.indent_char = None # type: Optional[str]
#: Current level of indentation
self.indent_level = 0
+ #: Number of spaces used for indentation
+ self.indent_size = options.indent_size
+ #: String representing the space indentation
+ self.indent_size_str = self.indent_size * " "
#: Line number in the file
self.line_number = 0
#: Current logical line
diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py
index 85afa20..e2f58c5 100644
--- a/tests/integration/test_main.py
+++ b/tests/integration/test_main.py
@@ -252,7 +252,6 @@ t.py:2:6: W292 no newline at end of file
'''
-@pytest.mark.xfail(strict=True) # currently awaiting fix in pycodestyle
def test_physical_line_file_not_ending_in_newline_trailing_ws(tmpdir, capsys):
"""See https://github.com/PyCQA/pycodestyle/issues/960."""
t_py_src = 'x = 1 '
@@ -264,7 +263,7 @@ def test_physical_line_file_not_ending_in_newline_trailing_ws(tmpdir, capsys):
out, err = capsys.readouterr()
assert out == '''\
t.py:1:6: W291 trailing whitespace
-t.py:1:10: W292 no newline at end of file
+t.py:1:9: W292 no newline at end of file
'''
diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py
index eb76f98..a407b50 100644
--- a/tests/unit/conftest.py
+++ b/tests/unit/conftest.py
@@ -9,6 +9,7 @@ def options_from(**kwargs):
kwargs.setdefault('hang_closing', True)
kwargs.setdefault('max_line_length', 79)
kwargs.setdefault('max_doc_length', None)
+ kwargs.setdefault('indent_size', 4)
kwargs.setdefault('verbose', False)
kwargs.setdefault('stdin_display_name', 'stdin')
kwargs.setdefault('disable_noqa', False)