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

[options-] disable adding rows #1944

Merged
merged 1 commit into from
Jul 1, 2023
Merged

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Jul 1, 2023

Running add-row on the OptionsSheet produces an error:

  File "/home/midichef/.local/lib/python3.8/site-packages/visidata/basesheet.py", line 200, in execCommand
    escaped = super().execCommand2(cmd, vdglobals=vdglobals)
  File "/home/midichef/.local/lib/python3.8/site-packages/visidata/basesheet.py", line 73, in execCommand2
    exec(code, vdglobals, LazyChainMap(vd, self))
  File "add-row", line 1, in <module>
  File "/home/midichef/.local/lib/python3.8/site-packages/visidata/sheets.py", line 212, in newRow
    return type(self)._rowtype()
TypeError: __init__() missing 2 required positional arguments: 'name' and 'value'

This commit disables add-row for OptionsSheet.

I also explored adding an empty row by making OptionsSheet.newRow():

def newRow(self):
    return vd.option(None, None, None, None)

but I was not able to edit the name field of the resulting row, only the value.

Copy link
Owner

@saulpw saulpw left a comment

Choose a reason for hiding this comment

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

Makes sense to me. BTW, vd.fail raises an exception, so the return is unreachable. Also we don't need an empty return in Python anyway (some people prefer to be explicit, but I prefer to elide it).

@anjakefala anjakefala merged commit 694680f into saulpw:develop Jul 1, 2023
13 checks passed
@midichef midichef deleted the options_addrow branch July 2, 2023 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants