Skip to content

Add annotations to String #5558

Closed
Closed

Description

@pekkaklarck

Let's use this issue for discussing String typing to avoid flooding the main issue with String related comments.

Could you @silentw0lf list the open issues here?

Activity

  1. added this to the v7.4 milestone on Nov 21, 2025
  2. removed this from the v7.4 milestone on Nov 21, 2025
  3. silentw0lf commented on Nov 23, 2025

    @silentw0lf
    Contributor

    Just copied notes from the main issue:

    I will look into the MR for Strings now: #5497

    by reading through our discussions above, I see the the following tasks:

    • Remove check within function that test differnt type (than in param, andthen raise) + there tests[x] remove @keyword(types=None) since types provided* [ ] backwards compatibility (potentially > 30 functions)

      • provide param str | bytes args where possible (i have to check for each parameter, if the functions in the keyword can also be called on a buytes objects - no quick job)* add tests too (i hope this will not take forever, will only include basics)* (no code changes to add bytes support (stay with str))[x] Literal support (see DateTime)[ ] Adding a note like "Some keywords also work with bytes in addition to strings."

    rebased upstream/master and pushed commits: #5554

    @pekkaklarck) I have implemented the tasks as far as I can. Problems remain with bytes support. Where I couldn't make a decision myself, I added a TODO(@pekkaklarck) to the functions with information.

    The problem concerns backwards compatibility for keywords. Either

    [1] You allow bytes—then a test function must truly support it (which is particularly difficult when there are 2-3 parameters that can each be either bytes or str influencing each other during code paths; in many cases that's simply not possible -> high risk for bugs).

    [2] You don't allow bytes, because you can't support all parameter combinations—however, this would break older Robot versions if a user happened to use the one parameter combination that used to work (other type combinations would also then not work).

    [3] Where bytes can't be safely introduced 100%, we can leave it as str, and there will be a few special cases where backwards compatibility cannot be maintained.

    Could you perhaps adjust the remaining places according to your preferences in the MR?
    Otherwise, I think the discussions will drag on for a long time back and forth, even though the implementation is already 95% finished.

    local latests and utests PASS but there is some empty error porblem in the pipeline:

    Image
  4. silentw0lf commented on Nov 23, 2025

    @silentw0lf
    Contributor

    The MR can be reviewed.

    • I added str | bytes were there should be no side effects (and added some tests).
    • I did not add str | bytes where different parameters could have different types (e.g. string as str and exclude as bytes, and so on) -> left a comment at those functions with TODO(...pekkaklarck) if you want to discuss. They are of course removed when MR is ready.
  5. pekkaklarck commented on Nov 27, 2025

    @pekkaklarck
    MemberAuthor

    I don't have time to review this now, but after XML finally being ready, this one is next in my agenda.

    One thing I wanted to note is that String has some keywords that are affected by #5558 #5537. There's no need to deprecate anything as part of this issue, but it is likely that the affected keywords need to have Literal[""] as one accepted value for the start index. There ought to be tests for validating that the empty string is currently accepted and they ought to fail without that typing.

  6. silentw0lf commented on Nov 30, 2025

    @silentw0lf
    Contributor

    I don't have time to review this now, but after XML finally being ready, this one is next in my agenda.

    One thing I wanted to note is that String has some keywords that are affected by #5558. There's no need to deprecate anything as part of this issue, but it is likely that the affected keywords need to have Literal[""] as one accepted value for the start index. There ought to be tests for validating that the empty string is currently accepted and they ought to fail without that typing.

    here is a self reference: 5558 -> 5558

  7. pekkaklarck commented on Nov 30, 2025

    @pekkaklarck
    MemberAuthor

    Right, the correct reference is #5537.

  8. pekkaklarck commented on Dec 1, 2025

    @pekkaklarck
    MemberAuthor

    Implemented in PR #5554 by @silentw0lf. Thanks for the contribution!

  9. added a commit that references this issue on Dec 1, 2025
    fcb0f80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions