Skip to content

Conversation

JFoederer
Copy link
Contributor

@JFoederer JFoederer commented May 4, 2025

Update to the @library decorator that accepts @library(auto_keywords=None) to suppress the (very prominent) 'contains no keywords' warning as shown in this example.

image

Other than suppressing the warning it behaves identical to @library(auto_keywords=False)

@JFoederer
Copy link
Contributor Author

Hi @pekkaklarck, can you please review this PR?

I basically have 2 questions:

  • What is your opinion on suppressing this warning?
  • Is the low-impact way of 'abusing' the existing auto_keywords option the preferred way?

The alternative would be to have a separate option, but I feel this might be overkill for such a niche option.

@pekkaklarck
Copy link
Member

pekkaklarck commented May 7, 2025

auto_keywords=None is both clever and hacky. It's certainly better than a separate parameter for this niche use case. Related to that, could you explain your use case for this behavior? Why would you have a library without any keywords? Instead of explaining that here, you could submit an issue because we'd anyway need one for tracking purposes.

Notice also that there's another way to avoid this warning: adding a listener to the library. Listeners don't need to have any listener methods and nowadays don't even need to ROBOT_LISTENER_API_VERSION attribute, so you could probably use just @library(listener=object()).

@JFoederer
Copy link
Contributor Author

I agree it is hacky, but to be honest, turning it into a fake listener sounds even more hacky than auto_keywords=None. It would do the trick, though. But I must add that I wouldn't have thought of this option, even after reading the documentation and seeing the source code. I hadn't realised that empty unregistered listeners would work.

I will submit the issue and then we have three options: accept it as-is, reject it and keep using the listener or find a pretty solution.

@JFoederer
Copy link
Contributor Author

While writing down the issue I dropped one of the two use cases. Reflecting on it made me realise I didn't need those files loaded in Robot. Having the objects sufficed. The other one is described in the issue I linked.

@s-wozny
Copy link

s-wozny commented Aug 28, 2025

I agree it is hacky, but to be honest, turning it into a fake listener sounds even more hacky than auto_keywords=None

Hi, I totally agree with you!
In my use case, the library is used to enforce a default User-Agent header on all outbound HTTP requests made with the requests library by "patching" the request function. Unfortunately, I couldn't find any global option or config to handle this specific need. So, I don't actually need a keyword in this case. :)

Does anyone knows if auto_keywords=None will be available, and when?
Using listener=object() works for me as well now, but I’m not a big fan of this “hacky” workaround.

@pekkaklarck
Copy link
Member

@s-wozny, could you explain your use case in issue #5429 that's used for tracking this enhancement? Having more than one use case proves the feature would be generally useful.

@s-wozny
Copy link

s-wozny commented Aug 29, 2025

All done, thanks for the quick response !

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.

3 participants