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

Use standard types.SimpleNamespace instead of custom struct #1480

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions labelme/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import os.path as osp
import re
import types
import webbrowser

import imgviz
Expand Down Expand Up @@ -622,7 +623,7 @@ def __init__(
self.labelList.customContextMenuRequested.connect(self.popLabelListMenu)

# Store actions for further handling.
self.actions = utils.struct(
self.actions = types.SimpleNamespace(
saveAuto=saveAuto,
saveWithImageData=saveWithImageData,
changeOutputDir=changeOutputDir,
Expand Down Expand Up @@ -715,7 +716,7 @@ def __init__(

self.canvas.vertexSelected.connect(self.actions.removePoint.setEnabled)

self.menus = utils.struct(
self.menus = types.SimpleNamespace(
file=self.menu(self.tr("&File")),
edit=self.menu(self.tr("&Edit")),
view=self.menu(self.tr("&View")),
Expand Down
1 change: 0 additions & 1 deletion labelme/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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
5 changes: 0 additions & 5 deletions labelme/utils/qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ def labelValidator():
return QtGui.QRegExpValidator(QtCore.QRegExp(r"^[^ \t].+"), None)


class struct(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)


def distance(p):
return sqrt(p.x() * p.x() + p.y() * p.y())

Expand Down