Skip to content

test_util: Improve type hints for test_get_random_game_name #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sonic2kk
Copy link
Contributor

Improve type hints for the unit test test_get_random_game_name, which also leads to improving the type hints for the util#get_random_game_name function, which was incorrect (it was hinting for a single list which could have Steam Games, Lutris Games, and/or Heroic Games, instead of a list which would only contain one of these types rather than any combination).

This also means we get rid of some deprecated types in util.py.

Adding hints to unit tests and the functions they are testing is a good pairing imo; we are improving the hints of the actual function, and being explicit about the types we are expecting in our tests.

@sonic2kk sonic2kk force-pushed the improve-hint-for-test-get-random-game-name branch from 612650c to 7415a10 Compare July 28, 2024 19:12
@DavidoTek
Copy link
Owner

Thanks!

it was hinting for a single list which could have Steam Games, Lutris Games, and/or Heroic Games, instead of a list which would only contain one of these types rather than any combination

Good catch.

random_game: SteamApp | LutrisGame | HeroicGame

I wonder if we want to add type definitions for this to constants.py/types.py ? in the future. Something like AnyGame = SteamApp | LutrisGame | HeroicGame.

@DavidoTek DavidoTek merged commit ec20c1f into DavidoTek:main Jul 31, 2024
1 check passed
@sonic2kk
Copy link
Contributor Author

I like that idea, we may also want to do this for other things like parsing JSON and VDF files (arguably both of these should be upstream and perhaps we can ask upstream VDF to improve type hinting if possible).

Definitely room to improve our typing 😄 Not that it's majorly urgent, just something that can be worked on overtime

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