Skip to content

test: add type hinting to test_helpers#1014

Merged
benhoyt merged 6 commits intocanonical:mainfrom
tonyandrewmeyer:pyright-test_helpers-1007
Sep 26, 2023
Merged

test: add type hinting to test_helpers#1014
benhoyt merged 6 commits intocanonical:mainfrom
tonyandrewmeyer:pyright-test_helpers-1007

Conversation

@tonyandrewmeyer
Copy link
Collaborator

  • Add type hints to tests/test_helpers
  • For fake_script and fake_script_calls, there are a bunch of type: ignores to work around not being able to state the type of fake_script_path - I think there will be a few of these through other test modules as well, as hints are added there. I feel it would be cleaner to have the fake script functionality in a class rather than dynamically added to TestCase instances, but that is a much more substantial change

Partially addresses #1007

Copy link
Collaborator

@benhoyt benhoyt left a comment

Choose a reason for hiding this comment

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

Huh, yeah, some of these are definitely messy. Oh well, if it helps us get type checks turned on on our test directory, I think it's worth it.

path = test_case.fake_script_path / name
with path.open('wt') as f:
path: pathlib.Path = test_case.fake_script_path / name # type: ignore
with path.open('wt') as f: # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, the joys of Python type checking! :-)

@benhoyt benhoyt merged commit b2c4a3e into canonical:main Sep 26, 2023
@tonyandrewmeyer tonyandrewmeyer deleted the pyright-test_helpers-1007 branch September 26, 2023 04:47
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