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

Change "is not" to "!=" when checking literals #886

Open
wants to merge 1 commit into
base: 1.2.1-release
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
2 changes: 1 addition & 1 deletion gooey/gui/components/widgets/bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def getUiState(self) -> t.FormField:
def syncUiState(self, state: FormField): # type: ignore
self.widget.setValue(state['value']) # type: ignore
self.error.SetLabel(state['error'] or '')
self.error.Show(state['error'] is not None and state['error'] is not '')
self.error.Show(state['error'] is not None and state['error'] != '')
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it enough to write

self.error.Show(bool(state['error']))

?

Copy link
Author

Choose a reason for hiding this comment

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

That seems to work as well, assuming we want other falsy values to equate to false as well (such as 0).



def getValue(self) -> t.FieldValue:
Expand Down
2 changes: 1 addition & 1 deletion gooey/gui/components/widgets/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def syncUiState(self, state: t.Checkbox): # type: ignore
checkbox.Enable(state['enabled'])
self.Show(state['visible'])
self.error.SetLabel(state['error'] or '')
self.error.Show(state['error'] is not None and state['error'] is not '')
self.error.Show(state['error'] is not None and state['error'] != '')



Expand Down
2 changes: 1 addition & 1 deletion gooey/gui/components/widgets/dropdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def syncUiState(self, state: FormField):
if state['selected'] is not None: # type: ignore
self.setValue(state['selected']) # type: ignore
self.error.SetLabel(state['error'] or '')
self.error.Show(state['error'] is not None and state['error'] is not '')
self.error.Show(state['error'] is not None and state['error'] != '')

def getUiState(self) -> t.FormField:
widget: wx.ComboBox = self.widget
Expand Down
2 changes: 1 addition & 1 deletion gooey/gui/components/widgets/dropdown_filterable.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def syncUiState(self, state: t.DropdownFilterable): # type: ignore
if state['value'] is not None:
self.setValue(state['value'])
self.error.SetLabel(state['error'] or '')
self.error.Show(state['error'] is not None and state['error'] is not '')
self.error.Show(state['error'] is not None and state['error'] != '')

def OnGetItem(self, n):
return self.model.suggestions[n]
Expand Down
2 changes: 1 addition & 1 deletion gooey/gui/components/widgets/listbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ def syncUiState(self, state: t.Listbox): # type: ignore
for string in state['selected']:
widget.SetStringSelection(string)
self.error.SetLabel(state['error'] or '')
self.error.Show(state['error'] is not None and state['error'] is not '')
self.error.Show(state['error'] is not None and state['error'] != '')
2 changes: 1 addition & 1 deletion gooey/gui/components/widgets/textarea.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def formatOutput(self, metatdata, value: str):
def syncUiState(self, state: FormField):
self.setValue(state['value']) # type: ignore
self.error.SetLabel(state['error'] or '')
self.error.Show(state['error'] is not None and state['error'] is not '')
self.error.Show(state['error'] is not None and state['error'] != '')

def getUiState(self) -> t.FormField:
return t.TextField(
Expand Down
2 changes: 1 addition & 1 deletion gooey/gui/components/widgets/textfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ def syncUiState(self, state: t.TextField): # type: ignore
textctr.Enable(state['enabled'])
self.Show(state['visible'])
self.error.SetLabel(state['error'] or '')
self.error.Show(state['error'] is not None and state['error'] is not '')
self.error.Show(state['error'] is not None and state['error'] != '')
self.Layout()