Skip to content

Update application.py#2526

Closed
elegantiron wants to merge 1 commit intopythonarcade:developmentfrom
elegantiron:patch-1
Closed

Update application.py#2526
elegantiron wants to merge 1 commit intopythonarcade:developmentfrom
elegantiron:patch-1

Conversation

@elegantiron
Copy link
Contributor

fixes type hinting to match the returned properties

fixes #2525

fixes type hinting to match the returned properties

fixes pythonarcade#2525
Copy link
Member

@pushfoo pushfoo left a comment

Choose a reason for hiding this comment

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

Although it may seem counter-intuitive, the float option may be more correct:

  1. Mac uses float pairs for their screen locations (example)
  2. Other platforms may as well

This affects future mobile and web support plans as well, but it's a long-standing issue which affects pyglet.

@elegantiron
Copy link
Contributor Author

Although it may seem counter-intuitive, the float option may be more correct:

Personally, I just want my type checker to chill out; I don't care which is more correct.

If float is the more correct one, then should we change the __init__ functions to type hint that they accept floats?

I'm getting the following from pylance:

Argument of type "float" cannot be assigned to parameter "width" of type "int" in function "__init__"
  "float" is not assignable to "int"

And it is complaining about the following code:

self.title_section = TitleSection(0, 0, self.width, self.height)

This is a view attempting to create a section that is the same size as itself, but Pylance is unhappy that the types don't match.

@eruvanos
Copy link
Member

Could we just allow float or int, both would work right?

@elegantiron
Copy link
Contributor Author

That would solve my personal issue with it (type checking), and if it works for the technical side too I'm all for it.

@elegantiron
Copy link
Contributor Author

I'm going to open a new pull request with changes to sections.py which hint that it accepts int or float

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.

arcade.View hints the wrong type for height and width

3 participants