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

Fix single-arg Coordinate() constructor #8

Merged
merged 2 commits into from
Jun 18, 2024

Conversation

sgt0
Copy link
Contributor

@sgt0 sgt0 commented Jun 18, 2024

Coordinate() has a single-arg (not counting the self arg) constructor overload that is unusable because the overloaded constructor requires two args.

from stgpytools import Coordinate
    
Coordinate((0, 0))
# TypeError: Coordinate.__init__() missing 1 required positional argument: 'y'

This is caught by mypy but the error was being type: ignore'd. This patch fixes the issue by making the y arg optional in the overloaded constructor's signature (but it's still required overall).

This was originally discovered via vs-masktool's BoundingBox:

from vsmasktools import BoundingBox
    
BoundingBox((0, 0), (100, 100))
#   File "vs-masktools/vsmasktools/abstract.py", line 36, in __init__
#     self.pos, self.size, self.invert = Position(pos), Size(size), invert
#                                        ^^^^^^^^^^^^^
# TypeError: Coordinate.__init__() missing 1 required positional argument: 'y'

sgt0 added 2 commits June 18, 2024 16:15
`Coordinate()` has a single-arg (not counting the `self` arg)
constructor overload that is unusable because the overloaded constructor
requires two args.

    from stgpytools import Coordinate

    Coordinate((0, 0))
    # TypeError: Coordinate.__init__() missing 1 required positional argument: 'y'

This is caught by mypy but the error was being `type: ignore`'d. This
patch fixes the issue by making the `y` arg optional in the overloaded
constructor's signature (but it's still required overall).

This was originally discovered via vs-masktool's `BoundingBox`:

    from vsmasktools import BoundingBox

    BoundingBox((0, 0), (100, 100))
    #   File "vs-masktools/vsmasktools/abstract.py", line 36, in __init__
    #     self.pos, self.size, self.invert = Position(pos), Size(size), invert
    #                                        ^^^^^^^^^^^^^
    # TypeError: Coordinate.__init__() missing 1 required positional argument: 'y'
@Setsugennoao Setsugennoao merged commit c91a97b into Setsugennoao:master Jun 18, 2024
1 check passed
@sgt0 sgt0 deleted the coordinate-args branch June 18, 2024 17:15
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