Skip to content

Properties with setters lack type annotations #272

Closed
@aatle

Description

@aatle

Problem:
Almost all of the settable properties (such as Body.mass) are dynamically defined, so mypy doesn't recognize them. The properties get inferred to be of type Any (from the mixin), which is undesirable.

Suggestion:
Rewrite most of the writable properties in normal syntax, putting their docstring in the getter function. Static type checkers can then correctly see their type.
I can make the PR.

Exception:
Some properties are of Vec2d and so their setter accepts tuples, a different type than the getter. It has been pointed out before that type checkers don't recognize this.
So, these properties will be left alone.
Note: Mypy 1.16 adds support for getters and setters with different types. See the release notes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions