question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG - Develop] CmdSet.remove() does not take string args

See original GitHub issue

Describe the bug

Not sure if it’s a documentation error or a code error - this claims that you can pass it the key of a command to remove, but causes a traceback. https://github.com/evennia/evennia/blob/7f4769bd9d3403b8011998b0c903a490caa07be9/evennia/commands/cmdset.py#L566-L568

To Reproduce

Steps to reproduce the behavior:

  1. Attempt to remove a command from any CmdSet with the key, e.g. self.remove("charcreate")
  2. The code gives a traceback because it cannot handle a string.

Expected behavior

Either it should remove the command in the set with that key or the docstring is inaccurate.

Develop-branch commit

7f4769bd9

Additional context

The traceback:

Traceback (most recent call last):
  File ".../evennia/evennia/commands/cmdsethandler.py", line 208, in import_cmdset
    cmdsetclass = cmdsetclass(cmdsetobj)
  File ".../evennia/evennia/commands/cmdset.py", line 222, in __init__
    self.at_cmdset_creation()
  File "./accounts/commands.py", line 27, in at_cmdset_creation
    self.remove("charcreate")
  File ".../evennia/evennia/commands/cmdset.py", line 572, in remove
    if cmd.key.startswith("__"):
AttributeError: 'str' object has no attribute 'key'

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
Griatchcommented, Jun 7, 2022

Hm. I think the docstring is correct; it’s consistent with the rest of the system to support removal both by cmd, key or even cmd-class-path. I don’t recall why this was never implemented, but most likely it’s because I mainly thought of CmdsetHandler.remove as being the main thing people would use. As it turns out, Cmdset.remove() is a much more common use case than expected, since this is the easiest way to remove default commands.

1reaction
Griatchcommented, May 7, 2022

Looks like a code bug; everyone’s been using this with the command object 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

C++ STL remove error - string - Stack Overflow
The error he got was because there is another function that takes a single argument, called "remove", which deletes a file. Share.
Read more >
Set - Environment Variable - Windows CMD - SS64.com
Display, set, or remove CMD environment variables. Changes made with SET will remain only for the duration of the current CMD session.
Read more >
Add useful error messages when using list of arguments #1383
When having a list of arguments of a certain type, and the type conversion fails at one argument the TypeConversionException is converted to...
Read more >
shell_exec - Manual - PHP
A string containing the output from the executed command, false if the pipe cannot be established or null if an error occurs or...
Read more >
PyMOL Command Reference
USAGE drag [ selection ] ARGUMENTS selection = string: atoms to drag. If not provided, and dragging is active, then dragging is instead...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found