Skip to content
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

Typehint warnings #86

Closed
wants to merge 4 commits into from
Closed

Conversation

SpideyWacko
Copy link
Contributor

Fixed linter and type hint warnings without changing functionality, mostly for PyCharm compatibility.

@SpideyWacko SpideyWacko marked this pull request as draft May 3, 2024 03:26
Copy link
Owner

@Grimmys Grimmys left a comment

Choose a reason for hiding this comment

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

I like what you are doing, code smells to the trash!

@@ -738,7 +738,7 @@ def get_next_cases(self, position: Position) -> list[Optional[Entity]]:
return tiles_content

def get_possible_moves(
self, position: Position, max_moves: int
self, position: tuple, max_moves: int
Copy link
Owner

Choose a reason for hiding this comment

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

feel like we are loosing some level of precision about the structure of position arg here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change doesn't make sense, must've been an overzealous mistake on my part.

@@ -828,7 +828,7 @@ def is_tile_available(self, tile: Position) -> bool:

return entity_on_tile is None

def get_entity_on_tile(self, tile: Position) -> Optional[Entity]:
def get_entity_on_tile(self, tile: Position) -> Optional[Entity, Destroyable]:
Copy link
Owner

Choose a reason for hiding this comment

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

Destroyable is an Entity.
Why adding it to the typing while it's already included?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there was a downstream complaint by a function expecting a Destroyable. Hopefully this will be clearer when I roll back to a less ambitious PR.

@@ -843,7 +843,7 @@ def get_entity_on_tile(self, tile: Position) -> Optional[Entity]:
return None

def determine_path_to(
self, destination_tile: Position, distance_for_tile: dict[tuple[int, int], int]
self, destination_tile: Position, distance_for_tile: dict[tuple, int]
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe it should be Position instead of tuple

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense, I think I made this change before I realized there was a Position class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying it again, and it may be because Position is a Union with pygame.Vector2, which isn't hashable for the set function.

Copy link
Owner

Choose a reason for hiding this comment

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

Indeed I remember something about it, can be annoying...

allies: Sequence[Movable] = (
self.players + self.entities.allies if is_ally else self.entities.foes
)
# allies: Sequence[Movable] = (
Copy link
Owner

Choose a reason for hiding this comment

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

I assume it's something you planned to fix later on because it's still only a draft PR (I know), but I'm putting this comment as a reminder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

allies doesn't actually get used by the duel function on line 1194. Seems like something that might get implemented in the future, so I didn't want to get rid of it entirely.

Copy link
Owner

Choose a reason for hiding this comment

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

Nah feel free to remove not used stuff.

We are using Git for a reason: if some later time we need these changes (because of a feature related to allies) then we could just get back what was removed by the commit.

Commented out code is a code smell, and is harmless to remove when having a good versioning system tool.

@@ -71,19 +71,19 @@ def __init__(self, screen: pygame.Surface) -> None:
self.level: Optional[LevelScene] = None
self.exit: QuitActionKind = QuitActionKind.CONTINUE

StartScene.load_options()
self.options_file = None
self.load_options()
Copy link
Owner

Choose a reason for hiding this comment

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

I think you need to rebase your branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll start from scratch and just change a reasonable number of scripts at a time. I think I started with level_scene.py, and the dependencies spiraled quicker than I expected.

@SpideyWacko SpideyWacko closed this May 6, 2024
@SpideyWacko SpideyWacko deleted the typehint_warnings branch May 6, 2024 21:19
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.

None yet

2 participants