Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better flake8 checks #1754

Merged
merged 4 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 18 additions & 16 deletions etstool.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# (C) Copyright 2004-2021 Enthought, Inc., Austin, TX
# All rights reserved.
#
# Copyright (c) 2017, Enthought, Inc.
# All rights reserved.
#
# This software is provided without warranty under the terms of the BSD
# license included in enthought/LICENSE.txt and may be redistributed only
# under the conditions described in the aforementioned license. The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!
# This software is provided without warranty under the terms of the BSD
# license included in LICENSE.txt and may be redistributed only under
# the conditions described in the aforementioned license. The license
# is also available online at http://www.enthought.com/licenses/BSD.txt
#
# Thanks for using Enthought open source!

"""
Tasks for Test Runs
===================
Expand Down Expand Up @@ -473,18 +472,21 @@ def test_all():
@click.option(
"--environment", default=None, help="Name of EDM environment to check."
)
def flake8(runtime, toolkit, environment):
@click.option(
'--strict/--not-strict',
default=False,
help="Use strict configuration for flake8 [default: --not-strict]",
)
def flake8(runtime, toolkit, environment, strict):
""" Run a flake8 check in a given environment.

"""
parameters = get_parameters(runtime, toolkit, environment)
targets = [
"examples",
"integrationtests",
"traitsui",
]
config = ""
if strict:
config = "--config=flake8_strict.cfg "
commands = [
"edm run -e {environment} -- python -m flake8 " + " ".join(targets)
"edm run -e {environment} -- python -m flake8 " + config,
]
execute(commands, parameters)

Expand Down
3 changes: 3 additions & 0 deletions flake8_strict.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
ignore = E266,W503,E722,E731,E741
per-file-ignores = */api.py:F401
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: missing newline

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I just tried to fix this using a suggestion, but it's not clear whether that's possible.)

166 changes: 10 additions & 156 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,158 +1,12 @@
[flake8]
exclude = docs
per-file-ignores = */api.py:F401,examples/*:H101
exclude =
# The following list should eventually be empty.
docs,
etstool.py,
examples/tutorials/traitsui_4.0,
integrationtests/styled_date_editor_test.py,
integrationtests/ui,
traitsui/editors/__init__.py,
traitsui/editors/color_editor.py
traitsui/editors/csv_list_editor.py
traitsui/editors/enum_editor.py
traitsui/editors/image_enum_editor.py
traitsui/editors/rgb_color_editor.py
traitsui/editors/shell_editor.py
traitsui/editors/table_editor.py
traitsui/examples/demo,
traitsui/extras,
traitsui/file_dialog.py,
traitsui/group.py,
traitsui/handler.py,
traitsui/help.py,
traitsui/image/image.py,
traitsui/include.py,
traitsui/item.py,
traitsui/list_str_adapter.py,
traitsui/menu.py,
traitsui/null,
traitsui/qt4/__init__.py,
traitsui/qt4/array_editor.py,
traitsui/qt4/basic_editor_factory.py,
traitsui/qt4/boolean_editor.py,
traitsui/qt4/button_editor.py,
traitsui/qt4/check_list_editor.py,
traitsui/qt4/clipboard.py,
traitsui/qt4/code_editor.py,
traitsui/qt4/color_editor.py,
traitsui/qt4/color_trait.py,
traitsui/qt4/compound_editor.py,
traitsui/qt4/constants.py,
traitsui/qt4/custom_editor.py,
traitsui/qt4/date_editor.py,
traitsui/qt4/date_range_editor.py,
traitsui/qt4/directory_editor.py,
traitsui/qt4/drop_editor.py,
traitsui/qt4/editor.py,
traitsui/qt4/editor_factory.py,
traitsui/qt4/enum_editor.py,
traitsui/qt4/file_editor.py,
traitsui/qt4/font_editor.py,
traitsui/qt4/font_trait.py,
traitsui/qt4/helper.py,
traitsui/qt4/history_editor.py,
traitsui/qt4/image_editor.py,
traitsui/qt4/image_enum_editor.py,
traitsui/qt4/instance_editor.py,
traitsui/qt4/key_binding_editor.py,
traitsui/qt4/key_event_to_name.py,
traitsui/qt4/list_editor.py,
traitsui/qt4/list_str_editor.py,
traitsui/qt4/list_str_model.py,
traitsui/qt4/menu.py,
traitsui/qt4/null_editor.py,
traitsui/qt4/progress_editor.py,
traitsui/qt4/range_editor.py,
traitsui/qt4/rgb_color_editor.py,
traitsui/qt4/rgb_color_trait.py,
traitsui/qt4/search_editor.py,
traitsui/qt4/set_editor.py,
traitsui/qt4/styled_date_editor.py,
traitsui/qt4/table_editor.py,
traitsui/qt4/table_model.py,
traitsui/qt4/tabular_editor.py,
traitsui/qt4/tabular_model.py,
traitsui/qt4/text_editor.py,
traitsui/qt4/time_editor.py,
traitsui/qt4/title_editor.py,
traitsui/qt4/toolkit.py,
traitsui/qt4/tree_editor.py,
traitsui/qt4/tree_node_renderers.py,
traitsui/qt4/tuple_editor.py,
traitsui/qt4/ui_base.py,
traitsui/qt4/ui_live.py,
traitsui/qt4/ui_modal.py,
traitsui/qt4/ui_panel.py,
traitsui/qt4/value_editor.py,
traitsui/qt4/view_application.py,
traitsui/qt4/extra/bounds_editor.py,
traitsui/table_column.py,
traitsui/table_filter.py,
traitsui/tabular_adapter.py,
traitsui/ui.py,
traitsui/ui_editors/__init__.py,
traitsui/ui_editors/data_frame_editor.py,
traitsui/ui_traits.py,
traitsui/undo.py,
traitsui/value_tree.py,
traitsui/view.py,
traitsui/wx/array_editor.py,
traitsui/wx/basic_editor_factory.py,
traitsui/wx/boolean_editor.py,
traitsui/wx/button_editor.py,
traitsui/wx/check_list_editor.py,
traitsui/wx/code_editor.py,
traitsui/wx/color_column.py,
traitsui/wx/color_editor.py,
traitsui/wx/color_trait.py,
traitsui/wx/compound_editor.py,
traitsui/wx/custom_editor.py,
traitsui/wx/date_editor.py,
traitsui/wx/directory_editor.py,
traitsui/wx/dnd_editor.py,
traitsui/wx/drop_editor.py,
traitsui/wx/editor.py,
traitsui/wx/editor_factory.py,
traitsui/wx/enum_editor.py,
traitsui/wx/extra/bounds_editor.py,
traitsui/wx/extra/windows/flash_editor.py,
traitsui/wx/extra/windows/ie_html_editor.py,
traitsui/wx/file_editor.py,
traitsui/wx/font_editor.py,
traitsui/wx/font_trait.py,
traitsui/wx/helper.py,
traitsui/wx/history_control.py,
traitsui/wx/history_editor.py,
traitsui/wx/html_editor.py,
traitsui/wx/image_editor.py,
traitsui/wx/image_enum_editor.py,
traitsui/wx/image_slice.py,
traitsui/wx/instance_editor.py,
traitsui/wx/key_binding_editor.py,
traitsui/wx/key_event_to_name.py,
traitsui/wx/list_editor.py,
traitsui/wx/list_str_editor.py,
traitsui/wx/menu.py,
traitsui/wx/null_editor.py,
traitsui/wx/popup_editor.py,
traitsui/wx/progress_editor.py,
traitsui/wx/range_editor.py,
traitsui/wx/rgb_color_trait.py,
traitsui/wx/scrubber_editor.py,
traitsui/wx/search_editor.py,
traitsui/wx/set_editor.py,
traitsui/wx/shell_editor.py,
traitsui/wx/table_model.py,
traitsui/wx/tabular_editor.py,
traitsui/wx/text_editor.py,
traitsui/wx/time_editor.py,
traitsui/wx/title_editor.py,
traitsui/wx/toolkit.py,
traitsui/wx/tree_editor.py,
traitsui/wx/tuple_editor.py,
traitsui/wx/ui_base.py,
traitsui/wx/ui_panel.py,
traitsui/wx/ui_wizard.py,
traitsui/wx/value_editor.py,
traitsui/wx/view_application.py,
ignore =
# codes we ignore as part of ETS style
E266,W503,E722,E731,E741
# codes we are ignoring pending clean-up
F401,F402,F403,F405,F406,F811,F841
E402,E712
# codes for formatting pending clean-up
E116,E121,E123,E126,E127,E128,E203,E226,E241,E251,E265,E272,E302,E303,E305,E306,E501
W291,W293,W504,W605
2 changes: 1 addition & 1 deletion traitsui/qt4/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def parse(self, menu, indent):
handler = line[col + 1 :].strip()
if handler != "":
if self.indirect:
self.indirect(cur_id, handler)
self.indirect(None, handler)
handler = self.indirect
else:
try:
Expand Down
4 changes: 2 additions & 2 deletions traitsui/qt4/styled_date_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def _styles_items_changed(self, event):
def _apply_style(self, style, dates):
""" **style** is a CellFormat, **dates** is a list of datetime.date """
for dt in dates:
self.set_unselected_style(style, date)
self.set_unselected_style(style, dt)
return

def _apply_styles(self, style_dict, date_dict):
Expand All @@ -115,4 +115,4 @@ def _apply_styles(self, style_dict, date_dict):
def _reset_formatting(self, dates):
# Resets the text format on the given dates
for dt in dates:
self.apply_unselected_style(date)
self.apply_unselected_style(dt)
5 changes: 3 additions & 2 deletions traitsui/wx/tree_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
"""


import os
import wx
import copy
from functools import partial
import os

import wx

try:
from pyface.wx.drag_and_drop import PythonDropSource, PythonDropTarget
Expand Down