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

Support for find_unit and find_unit_by_id #378

Merged

Conversation

332fg-raven
Copy link
Contributor

No description provided.

dcs/mission.py Outdated Show resolved Hide resolved
dcs/mission.py Outdated Show resolved Hide resolved
@332fg-raven 332fg-raven force-pushed the feature/miz-find_unit-and-find_unit_by_id branch from f458df2 to b8c948f Compare April 22, 2024 17:01
@332fg-raven
Copy link
Contributor Author

@rp- If I use List[Group] on groups, mypy shows errors:

dcs/mission.py:1862: error: Incompatible types in assignment (expression has type "list[StaticGroup | ShipGroup | VehicleGroup | PlaneGroup]", variable has type "list[Group[Any, Any]]")  [assignment]
dcs/mission.py:1862: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
dcs/mission.py:1862: note: Consider using "Sequence" instead, which is covariant
dcs/mission.py:1862: error: Unsupported operand types for + ("list[StaticGroup | ShipGroup | VehicleGroup | PlaneGroup]" and "list[HelicopterGroup]")  [operator]

If I use Sequence[Group] as suggested, I get the following:
dcs/mission.py:1862: error: Unsupported operand types for + ("list[StaticGroup | ShipGroup | VehicleGroup | PlaneGroup]" and "list[HelicopterGroup]") [operator]

I could use list[HelicopterGroup | StaticGroup | ShipGroup | VehicleGroup | PlaneGroup] or create a new alias for that.
Using none, does not give any warnings. Let me know if you want to keep it like that or should I revert back.

@rp-
Copy link
Collaborator

rp- commented Apr 22, 2024

@rp- If I use List[Group] on groups, mypy shows errors:

dcs/mission.py:1862: error: Incompatible types in assignment (expression has type "list[StaticGroup | ShipGroup | VehicleGroup | PlaneGroup]", variable has type "list[Group[Any, Any]]")  [assignment]
dcs/mission.py:1862: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
dcs/mission.py:1862: note: Consider using "Sequence" instead, which is covariant
dcs/mission.py:1862: error: Unsupported operand types for + ("list[StaticGroup | ShipGroup | VehicleGroup | PlaneGroup]" and "list[HelicopterGroup]")  [operator]

If I use Sequence[Group] as suggested, I get the following: dcs/mission.py:1862: error: Unsupported operand types for + ("list[StaticGroup | ShipGroup | VehicleGroup | PlaneGroup]" and "list[HelicopterGroup]") [operator]

I could use list[HelicopterGroup | StaticGroup | ShipGroup | VehicleGroup | PlaneGroup] or create a new alias for that. Using none, does not give any warnings. Let me know if you want to keep it like that or should I revert back.

I'm surpised mypy can't figure this out, until we have something wrong with the inheritance, but they all share the Group as base type.
But I'm fine with specifying nothing, as it is pretty clear to the reader I guess.

@rp- rp- merged commit b0bba2f into pydcs:master Apr 22, 2024
4 checks passed
@332fg-raven 332fg-raven deleted the feature/miz-find_unit-and-find_unit_by_id branch April 22, 2024 22:02
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