Skip to content

Potential Improvement: reduce object usage #1

@patrickhulce

Description

@patrickhulce

Thanks for publishing these, I love to see it ❤

At the moment they're quite limited in usefulness though. One suggestion would be to limit the use of object in these stubs. For example, ImageInput.open returns just object instead of ImageInput which basically ends all typechecking and misses out on all the great type hints defined on ImageInput. To illustrate, this is the sort of experience you get when I attempted to migrate to these types for a sample project.

  io_handling.py:76:30 - error: Cannot access attribute "read_image" for class "object"
    Attribute "read_image" is unknown (reportAttributeAccessIssue)
  io_handling.py:82:24 - error: Cannot access attribute "spec" for class "object"
    Attribute "spec" is unknown (reportAttributeAccessIssue)
  io_handling.py:83:17 - error: Cannot access attribute "close" for class "object"
    Attribute "close" is unknown (reportAttributeAccessIssue)
  io_handling.py:107:22 - error: Cannot access attribute "open" for class "object"
    Attribute "open" is unknown (reportAttributeAccessIssue)
  io_handling.py:108:22 - error: Cannot access attribute "write_image" for class "object"
    Attribute "write_image" is unknown (reportAttributeAccessIssue)
  io_handling.py:109:22 - error: Cannot access attribute "close" for class "object"
    Attribute "close" is unknown (reportAttributeAccessIssue)
  io_handling.py:138:81 - error: Cannot access attribute "get_error" for class "ImageBuf"
    Attribute "get_error" is unknown (reportAttributeAccessIssue)
  io_handling.py:149:42 - error: Argument of type "BASETYPE" cannot be assigned to parameter "dtype" of type "TypeDesc" in function "write"

I know they're auto-generated, which is great to keep update effort low, but it also means we can't migrate to them over hand-crafted typings 😄

Consider introducing an additional pass after the autogeneration where some minimal intelligence/manual patches could be added?

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