mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-03 03:56:52 +00:00
Add --stdin-display-name to modify report output
This commit is contained in:
parent
689562f1e8
commit
02bcbee245
3 changed files with 33 additions and 0 deletions
|
|
@ -192,6 +192,30 @@
|
|||
another-example*.py
|
||||
|
||||
|
||||
.. option:: --stdin-display-name=<display_name>
|
||||
|
||||
Provide the name to use to report warnings and errors from code on stdin.
|
||||
|
||||
Instead of reporting an error as something like:
|
||||
|
||||
.. code::
|
||||
|
||||
stdin:82:73 E501 line too long
|
||||
|
||||
You can specify this option to have it report whatever value you want
|
||||
instead of stdin.
|
||||
|
||||
This defaults to: ``stdin``
|
||||
|
||||
Command-line example:
|
||||
|
||||
.. prompt:: bash
|
||||
|
||||
cat file.py | flake8 --stdin-display-name=file.py -
|
||||
|
||||
This **can not** be specified in config files.
|
||||
|
||||
|
||||
.. option:: --format=<format>
|
||||
|
||||
Select the formatter used to display errors to the user.
|
||||
|
|
|
|||
|
|
@ -86,6 +86,13 @@ def register_default_options(option_manager):
|
|||
'separated list. (Default: %default)',
|
||||
)
|
||||
|
||||
add_option(
|
||||
'--stdin-display-name', default='stdin',
|
||||
help='The name used when reporting errors from code passed via stdin.'
|
||||
' This is useful for editors piping the file contents to flake8.'
|
||||
' (Default: %default)',
|
||||
)
|
||||
|
||||
# TODO(sigmavirus24): Figure out --first/--repeat
|
||||
|
||||
add_option(
|
||||
|
|
|
|||
|
|
@ -237,6 +237,8 @@ class StyleGuide(object):
|
|||
"""Handle an error reported by a check."""
|
||||
error = Error(code, filename, line_number, column_number, text,
|
||||
physical_line)
|
||||
if error.filename is None or error.filename == '-':
|
||||
error = error._replace(filename=self.options.stdin_display_name)
|
||||
error_is_selected = (self.should_report_error(error.code) is
|
||||
Decision.Selected)
|
||||
is_not_inline_ignored = self.is_inline_ignored(error) is False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue