diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 7cf3dea6f..000000000 --- a/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -exclude = .*/ -ignore = E203, E741, W503, W504 diff --git a/labelme/__init__.py b/labelme/__init__.py index a544e969a..2ab8c3ca4 100644 --- a/labelme/__init__.py +++ b/labelme/__init__.py @@ -1,11 +1,7 @@ -# flake8: noqa - -import logging import sys from qtpy import QT_VERSION - __appname__ = "labelme" # Semantic Versioning 2.0.0: https://semver.org/ @@ -17,12 +13,24 @@ QT4 = QT_VERSION[0] == "4" QT5 = QT_VERSION[0] == "5" -del QT_VERSION PY2 = sys.version[0] == "2" PY3 = sys.version[0] == "3" -del sys -from labelme.label_file import LabelFile +# These need to be later than the above definitions due to +# circular import dependencies. + from labelme import testing from labelme import utils +from labelme.label_file import LabelFile + +__all__ = [ + "__appname__", + "LabelFile", + "PY2", + "PY3", + "QT4", + "QT5", + "testing", + "utils", +] diff --git a/labelme/cli/__init__.py b/labelme/cli/__init__.py index 75751a56e..d44a080ba 100644 --- a/labelme/cli/__init__.py +++ b/labelme/cli/__init__.py @@ -1,6 +1,11 @@ -# flake8: noqa - from . import draw_json from . import draw_label_png from . import export_json from . import on_docker + +__all__ = [ + 'draw_json', + 'draw_label_png', + 'export_json', + 'on_docker', +] diff --git a/labelme/utils/__init__.py b/labelme/utils/__init__.py index 7fa2154fe..7388cde14 100644 --- a/labelme/utils/__init__.py +++ b/labelme/utils/__init__.py @@ -1,7 +1,4 @@ -# flake8: noqa - from ._io import lblsave - from .image import apply_exif_orientation from .image import img_arr_to_b64 from .image import img_arr_to_data @@ -11,19 +8,44 @@ from .image import img_data_to_png_data from .image import img_pil_to_data from .image import img_qt_to_arr - +from .qt import addActions +from .qt import distance +from .qt import distancetoline +from .qt import fmtShortcut +from .qt import labelValidator +from .qt import newAction +from .qt import newButton +from .qt import newIcon +from .qt import struct from .shape import labelme_shapes_to_label from .shape import masks_to_bboxes from .shape import polygons_to_mask from .shape import shape_to_mask from .shape import shapes_to_label -from .qt import newIcon -from .qt import newButton -from .qt import newAction -from .qt import addActions -from .qt import labelValidator -from .qt import struct -from .qt import distance -from .qt import distancetoline -from .qt import fmtShortcut +__all__ = [ + "addActions", + "apply_exif_orientation", + "distance", + "distancetoline", + "fmtShortcut", + "img_arr_to_b64", + "img_arr_to_data", + "img_b64_to_arr", + "img_data_to_arr", + "img_data_to_pil", + "img_data_to_png_data", + "img_pil_to_data", + "img_qt_to_arr", + "labelValidator", + "labelme_shapes_to_label", + "lblsave", + "masks_to_bboxes", + "newAction", + "newButton", + "newIcon", + "polygons_to_mask", + "shape_to_mask", + "shapes_to_label", + "struct", +] diff --git a/labelme/widgets/__init__.py b/labelme/widgets/__init__.py index 6283ef1e8..d2136f0b4 100644 --- a/labelme/widgets/__init__.py +++ b/labelme/widgets/__init__.py @@ -1,23 +1,27 @@ -# flake8: noqa - from .ai_prompt_widget import AiPromptWidget - from .brightness_contrast_dialog import BrightnessContrastDialog - from .canvas import Canvas - from .color_dialog import ColorDialog - from .file_dialog_preview import FileDialogPreview - from .label_dialog import LabelDialog from .label_dialog import LabelQLineEdit - from .label_list_widget import LabelListWidget from .label_list_widget import LabelListWidgetItem - from .tool_bar import ToolBar - from .unique_label_qlist_widget import UniqueLabelQListWidget - from .zoom_widget import ZoomWidget + +__all__ = [ + "AiPromptWidget", + "BrightnessContrastDialog", + "Canvas", + "ColorDialog", + "FileDialogPreview", + "LabelDialog", + "LabelQLineEdit", + "LabelListWidget", + "LabelListWidgetItem", + "ToolBar", + "UniqueLabelQListWidget", + "ZoomWidget", +] diff --git a/requirements-dev.txt b/requirements-dev.txt index 994f110c6..a2c8bf63b 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,5 @@ github2pypi==1.0.0 pytest pytest-qt -ruff==0.1.9 +ruff==0.5.7 twine diff --git a/ruff.toml b/ruff.toml index 205cc1d18..e524c154e 100644 --- a/ruff.toml +++ b/ruff.toml @@ -31,3 +31,8 @@ line-ending = "auto" [lint.isort] force-single-line = true + +[lint.per-file-ignores] +"**/__init__.py" = [ + "E402", # module level import not at top of file +]