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

Fixed a series of pylint issues #850

Open
wants to merge 1 commit into
base: master
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
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
"./gooey",
"-p",
"test*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
14 changes: 6 additions & 8 deletions gooey/gui/application/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import six
import wx # type: ignore

from rewx import components as c # type: ignore
from rewx import wsx # type: ignore
from rewx.core import Component, Ref # type: ignore

from gooey import Events
from gooey.gui import events
from gooey.gui import host
Expand All @@ -28,9 +32,7 @@
from gooey.python_bindings.types import Try
from gooey.util.functional import assoc
from gooey.gui.util.time import Timing
from rewx import components as c # type: ignore
from rewx import wsx # type: ignore
from rewx.core import Component, Ref # type: ignore



class RGooey(Component):
Expand Down Expand Up @@ -107,7 +109,7 @@ def component_did_mount(self):
if self.state['fullscreen']:
frame.ShowFullScreen(True)

if self.state['show_preview_warning'] and not 'unittest' in sys.modules.keys():
if self.state['show_preview_warning'] and not 'unittest' in sys.modules:
wx.MessageDialog(None, caption='YOU CAN DISABLE THIS MESSAGE',
message="""
This is a preview build of 1.2.0! There may be instability or
Expand Down Expand Up @@ -354,7 +356,3 @@ def render(self):
[c.StaticLine, {'style': wx.LI_HORIZONTAL, 'flag': wx.EXPAND}],
[RFooter, self.fprops(self.state)]]]
)




11 changes: 6 additions & 5 deletions gooey/gui/application/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import wx # type: ignore
from typing_extensions import TypedDict

from rewx import components as c # type: ignore
from rewx import wsx, mount, update # type: ignore
from rewx.core import Component, Ref # type: ignore
from rewx.widgets import set_basic_props # type: ignore

from gooey.gui.components.config import ConfigPage, TabbedConfigPage
from gooey.gui.components.console import Console
from gooey.gui.components.mouse import notifyMouseEvent
Expand All @@ -15,10 +20,7 @@
from gooey.gui.state import present_time
from gooey.gui.three_to_four import Constants
from gooey.python_bindings import constants
from rewx import components as c # type: ignore
from rewx import wsx, mount, update # type: ignore
from rewx.core import Component, Ref # type: ignore
from rewx.widgets import set_basic_props # type: ignore



def attach_notifier(parent):
Expand Down Expand Up @@ -331,4 +333,3 @@ def console(element, instance: Console):
if 'show' in element['props']:
instance.Show(element['props']['show'])
return instance

3 changes: 2 additions & 1 deletion gooey/gui/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
import wx.lib.inspection # type: ignore
import wx.richtext # type: ignore
import wx.xml # type: ignore
from rewx import render, create_element # type: ignore

from gooey.gui import image_repository
from gooey.gui.application.application import RGooey
from gooey.gui.lang import i18n
from gooey.util.functional import merge
from rewx import render, create_element # type: ignore



def run(build_spec):
Expand Down
21 changes: 10 additions & 11 deletions gooey/gui/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from copy import deepcopy

from gooey.util.functional import compact
from typing import List, Optional
from gooey.util.functional import compact

from gooey.gui.constants import VALUE_PLACEHOLDER
from gooey.gui.formatters import formatArgument
Expand All @@ -18,7 +18,7 @@
validateField :: Target -> Command -> Array Arg -> Array Arg -> ArgId -> CliString
completed :: Target -> Command -> FromState -> CliString
failed :: Target -> Command -> FromState -> CliString
fieldAction :: Target -> Command ->
fieldAction :: Target -> Command ->

'''

Expand All @@ -44,7 +44,7 @@ def formValidationCmd(target: str, subCommand: str, positionals: List[FieldValue
positional_args = [cmdOrPlaceholderOrNone(x) for x in positionals]
optional_args = [cmdOrPlaceholderOrNone(x) for x in optionals]
command = subCommand if not subCommand == '::gooey/default' else ''
return u' '.join(compact([
return ' '.join(compact([
target,
command,
*optional_args,
Expand All @@ -62,7 +62,7 @@ def cliCmd(target: str,
optional_args = [arg['cmd'] for arg in optionals]
command = subCommand if not subCommand == '::gooey/default' else ''
ignore_flag = '' if suppress_gooey_flag else '--ignore-gooey'
return u' '.join(compact([
return ' '.join(compact([
target,
command,
*optional_args,
Expand All @@ -81,15 +81,14 @@ def cmdOrPlaceholderOrNone(field: FieldValue) -> Optional[str]:
# it actually being missing.
if field['clitype'] == 'positional':
return field['cmd'] or VALUE_PLACEHOLDER
elif field['clitype'] != 'positional' and field['meta']['required']:
if field['clitype'] != 'positional' and field['meta']['required']:
# same rationale applies here. We supply the argument
# along with a fixed placeholder (when relevant i.e. `store`
# actions)
return field['cmd'] or formatArgument(field['meta'], VALUE_PLACEHOLDER)
else:
# Optional values are, well, optional. So, like usual, we send
# them if present or drop them if not.
return field['cmd']
# Optional values are, well, optional. So, like usual, we send
# them if present or drop them if not.
return field['cmd']


def buildCliString(target, subCommand, positional, optional, suppress_gooey_flag=False):
Expand All @@ -100,7 +99,7 @@ def buildCliString(target, subCommand, positional, optional, suppress_gooey_flag
arguments = ' '.join(compact(chain(optional, positionals)))

if subCommand != '::gooey/default':
arguments = u'{} {}'.format(subCommand, arguments)
arguments = '{} {}'.format(subCommand, arguments)

ignore_flag = '' if suppress_gooey_flag else '--ignore-gooey'
return u'{} {} {}'.format(target, ignore_flag, arguments)
return '{} {} {}'.format(target, ignore_flag, arguments)
3 changes: 1 addition & 2 deletions gooey/gui/components/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ConfigPage(ScrolledPanel):
self_managed = True

def __init__(self, parent, rawWidgets, buildSpec, *args, **kwargs):
super(ConfigPage, self).__init__(parent, *args, **kwargs)
super().__init__(parent, *args, **kwargs)

self.SetupScrolling(scroll_x=False, scrollToTop=False)
self.rawWidgets = rawWidgets
Expand Down Expand Up @@ -273,4 +273,3 @@ def layoutComponent(self):

def snapToErrorTab(self):
pass

4 changes: 1 addition & 3 deletions gooey/gui/components/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, parent, buildSpec, **kwargs):
self.getFontFace(),
))
self.textbox.SetForegroundColour(self.buildSpec['terminal_font_color'])

self.layoutComponent()
self.Layout()
self.Bind(wx.EVT_TEXT_URL, self.evtUrl, self.textbox)
Expand Down Expand Up @@ -100,5 +100,3 @@ def layoutComponent(self):
sizer.Add(self.textbox, 1, wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 20)
sizer.AddSpacer(20)
self.SetSizer(sizer)


5 changes: 1 addition & 4 deletions gooey/gui/components/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class HtmlDialog(wx.Dialog):
def __init__(self, *args, **kwargs):
caption = kwargs.pop('caption', '')
html = kwargs.pop('html', '')
super(HtmlDialog, self).__init__(None, *args, **kwargs)
super().__init__(None, *args, **kwargs)

wx.InitAllImageHandlers()

Expand All @@ -35,6 +35,3 @@ def __init__(self, *args, **kwargs):
sizer.Add(btnSizer, 0, wx.ALL | wx.EXPAND, 9)
self.SetSizer(sizer)
self.Layout()



8 changes: 4 additions & 4 deletions gooey/gui/components/filtering/prefix_filter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import re

import pygtrie as trie # type: ignore
from functools import reduce
import pygtrie as trie # type: ignore


__ALL__ = ('PrefixTokenizers', 'PrefixSearch')

Expand Down Expand Up @@ -38,7 +39,7 @@ def __init__(self,



class PrefixSearch(object):
class PrefixSearch():
"""
A trie backed index for quickly finding substrings
in a list of options.
Expand Down Expand Up @@ -86,8 +87,7 @@ def tokenizeChoice(self, choice):
return [token[i:]
for token in tokens
for i in range(len(token) - 2)]
else:
return tokens
return tokens

def clean(self, text):
return text.lower() if self.options.ignore_case else text
Expand Down
7 changes: 3 additions & 4 deletions gooey/gui/components/footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ def updateTimeRemaining(self,*args,**kwargs):
elapsed_time_value = kwargs.get('elapsed_time')
if elapsed_time_value is None:
return
elif estimate_time_remaining is not None:
if estimate_time_remaining is not None:
self.time_remaining_text.SetLabel(f"{elapsed_time_value}<{estimate_time_remaining}")
return
else:
self.time_remaining_text.SetLabel(f"{elapsed_time_value}")
self.time_remaining_text.SetLabel(f"{elapsed_time_value}")


def updateProgressBar(self, *args, **kwargs):
Expand Down Expand Up @@ -121,7 +120,7 @@ def _do_layout(self):

h_sizer.Add(self.progress_bar, 1,
wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 20)

h_sizer.Add(self.time_remaining_text,0,wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 20)

h_sizer.AddStretchSpacer(1)
Expand Down
2 changes: 1 addition & 1 deletion gooey/gui/components/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ def bindMouseEvents(self):
self._header.Bind(wx.EVT_LEFT_DOWN, notifyMouseEvent)
self._subheader.Bind(wx.EVT_LEFT_DOWN, notifyMouseEvent)
for image in self.images:
image.Bind(wx.EVT_LEFT_DOWN, notifyMouseEvent)
image.Bind(wx.EVT_LEFT_DOWN, notifyMouseEvent)
4 changes: 1 addition & 3 deletions gooey/gui/components/menubar.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MenuBar(wx.MenuBar):
"""

def __init__(self, buildSpec, *args, **kwargs):
super(MenuBar,self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.buildSpec = buildSpec
self.makeMenuItems(buildSpec.get('menu', []))

Expand Down Expand Up @@ -85,5 +85,3 @@ def spawnAboutDialog(self, item, *args, **kwargs):
getattr(about, method)(item[field])

three_to_four.AboutBox(about)


1 change: 0 additions & 1 deletion gooey/gui/components/modals.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ def confirmExit():
def confirmForceStop():
result = showDialog(_('stop_task'), _('sure_you_want_to_stop'), wx.YES_NO | wx.ICON_WARNING)
return result == DialogConstants.YES

4 changes: 2 additions & 2 deletions gooey/gui/components/mouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@


from gooey.gui.pubsub import pub
import gooey.gui.events as events
from gooey.gui import events

def notifyMouseEvent(event):
"""
Notify interested listeners of the LEFT_DOWN mouse event
"""
# TODO: is there ever a situation where this wouldn't be skipped..?
event.Skip()
pub.send_message_sync(events.LEFT_DOWN, wxEvent=event)
pub.send_message_sync(events.LEFT_DOWN, wxEvent=event)
7 changes: 3 additions & 4 deletions gooey/gui/components/options/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _include_global_option_docs(f):
Combines docstrings for options available to
all widget types.
"""
_doc = """:param initial_value: Sets the initial value in the UI.
_doc = """:param initial_value: Sets the initial value in the UI.
"""
f.__doc__ = (f.__doc__ or '') + _doc
return f
Expand All @@ -26,7 +26,7 @@ def _include_chooser_msg_wildcard_docs(f):
Combines the basic Chooser options (wildard, message) docsstring
with the wrapped function's doc string.
"""
_doc = """:param wildcard: Sets the wildcard, which can contain multiple file types, for
_doc = """:param wildcard: Sets the wildcard, which can contain multiple file types, for
example: "BMP files (.bmp)|.bmp|GIF files (.gif)|.gif"
:param message: Sets the message that will be displayed on the dialog.
"""
Expand All @@ -38,7 +38,7 @@ def _include_choose_dir_file_docs(f):
Combines the basic Chooser options (wildard, message) docsstring
with the wrapped function's doc string.
"""
_doc = """:param default_dir: The default directory selected when the dialog spawns
_doc = """:param default_dir: The default directory selected when the dialog spawns
:param default_file: The default filename used in the dialog
"""
f.__doc__ = (f.__doc__ or '') + _doc
Expand Down Expand Up @@ -331,4 +331,3 @@ def _clean(options):
cleaned = {k: v for k, v in options.items()
if v is not None and k != "layout_options"}
return {**options.get('layout_options', {}), **cleaned}

9 changes: 3 additions & 6 deletions gooey/gui/components/options/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from gooey.gui.components.filtering.prefix_filter import OperatorType


class SuperBool(object):
class SuperBool():
"""
A boolean which keeps with it the rationale
for when it is false.
Expand Down Expand Up @@ -117,12 +117,11 @@ def is_valid_color(value):
"""Must be either a valid hex string or RGB list"""
if is_str(value):
return is_hex_string(value)
elif is_tuple_or_list(value):
if is_tuple_or_list(value):
return (is_tuple_or_list(value)
and is_three_channeled(value)
and has_valid_channel_values(value))
else:
return is_str_or_coll(value)
return is_str_or_coll(value)


validators = {
Expand Down Expand Up @@ -197,5 +196,3 @@ def validate(pred, value):
# print(is_valid_color([255, 244, 256]))
# print(non_empty_string('asdf') and non_empty_string('asdf'))
# validate(is_valid_color, 1234)


5 changes: 1 addition & 4 deletions gooey/gui/components/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Sidebar(wx.Panel):
of the wx.Notebook class (which wants to control everything)
"""
def __init__(self, parent, buildSpec, configPanels, *args, **kwargs):
super(Sidebar, self).__init__(parent, *args, **kwargs)
super().__init__(parent, *args, **kwargs)
self._parent = parent
self.buildSpec = buildSpec
self.configPanels = configPanels
Expand Down Expand Up @@ -81,6 +81,3 @@ def layoutLeftSide(self):
container.AddSpacer(20)
self.leftPanel.SetSizer(container)
return self.leftPanel



2 changes: 1 addition & 1 deletion gooey/gui/components/tabbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Tabbar(wx.Panel):
def __init__(self, parent, buildSpec, configPanels, *args, **kwargs):
super(Tabbar, self).__init__(parent, *args, **kwargs)
super().__init__(parent, *args, **kwargs)
self._parent = parent
self.notebook = wx.Notebook(self, style=wx.BK_DEFAULT)
self.buildSpec = buildSpec
Expand Down
2 changes: 1 addition & 1 deletion gooey/gui/components/util/wrapped_static_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AutoWrappedStaticText(wx.StaticText):

def __init__(self, parent, *args, **kwargs):
self.target = kwargs.pop('target', None)
super(AutoWrappedStaticText, self).__init__(parent, *args, **kwargs)
super().__init__(parent, *args, **kwargs)
self.label = kwargs.get('label')
self.Bind(wx.EVT_SIZE, self.OnSize)
self.parent = parent
Expand Down
Loading