Skip to content

Enhance setup and teardown typing for TestSuite and TestCase - #4773

Merged
pekkaklarck merged 4 commits into
robotframework:masterfrom
Serhiy1:dev/type-hinting
May 29, 2023
Merged

pekkaklarck merged 4 commits into
robotframework:masterfrom
Serhiy1:dev/type-hinting

Conversation

@Serhiy1

@Serhiy1 Serhiy1 commented May 24, 2023

Copy link
Copy Markdown
Contributor

running.TestSuite and result.TestSuite now return correct setup and teardown keyword types
running.TestCase and result.TestCase now also return correct setup and teardown keyword types

Part of #4570

@Serhiy1 Serhiy1 changed the title Enhance setup and teardown for TestSuite and TestCase Enhance setup and teardown typing for TestSuite and TestCase May 24, 2023
prevents undefined reference when using the suite visitor API
@Serhiy1
Serhiy1 force-pushed the dev/type-hinting branch from e2949f2 to 4e6416a Compare May 24, 2023 11:49
@pekkaklarck

Copy link
Copy Markdown
Member

Looks good otherwise, but I don't understand why SuiteVisitor is changed. It is not meant to be used with robot.model objects, but it has them in its type hints because it works both with robot.running and robot.result structures. This is explained in the API docs.

The indented usage is extending SuiteVisitor, letting IDE to import type hints, and then updating imports as needed. That only works if type names don't change.

@Serhiy1

Serhiy1 commented May 25, 2023

Copy link
Copy Markdown
Contributor Author

@pekkaklarck The type args need to be filled out. Otherwise, all of the type hints fail to produce any meaningful IDE autocomplete.

image

VS

image

@pekkaklarck

Copy link
Copy Markdown
Member

robot.model.TestSuite not having proper completion is ok as long as extending classes have it. The type hint for SuiteVisitor must be TestSuite.

@pekkaklarck
pekkaklarck merged commit cb59448 into robotframework:master May 29, 2023
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.

2 participants