Skip to content

Add types for #56 Missing type annotations #60

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

Merged
merged 2 commits into from
May 9, 2022

Conversation

matt-land
Copy link
Contributor

@matt-land matt-land commented May 3, 2022

#56 This is not yet mypy passing, but it is intended for merge as is. It will likely need more work after #59. This is about as good as it gets for now. The remaining issues are due to type juggling (reassigning references from one type to another):


% mypy .
adafruit_imageload/gif.py:54: error: "None" not callable
adafruit_imageload/pnm/ppm_binary.py:53: error: Unsupported target for indexed assignment ("Callable[[int], Palette]")
adafruit_imageload/pnm/ppm_binary.py:63: error: Unsupported target for indexed assignment ("Callable[[int, int, int], Bitmap]")
adafruit_imageload/pnm/ppm_binary.py:63: error: "Set[Tuple[int, int, int]]" has no attribute "index"
adafruit_imageload/pnm/ppm_binary.py:68: error: Incompatible return value type (got "Tuple[Optional[Callable[[int, int, int], Bitmap]], Optional[Callable[[int], Palette]]]", expected "Tuple[Optional[Bitmap], Optional[Palette]]")
adafruit_imageload/pnm/ppm_ascii.py:61: error: Unsupported target for indexed assignment ("Callable[[int], Palette]")
adafruit_imageload/pnm/ppm_ascii.py:69: error: Unsupported target for indexed assignment ("Callable[[int, int, int], Bitmap]")
adafruit_imageload/pnm/ppm_ascii.py:69: error: "Set[bytes]" has no attribute "index"
adafruit_imageload/pnm/ppm_ascii.py:71: error: Incompatible return value type (got "Tuple[Optional[Callable[[int, int, int], Bitmap]], Optional[Callable[[int], Palette]]]", expected "Tuple[Optional[Bitmap], Optional[Palette]]")
adafruit_imageload/pnm/pgm/binary.py:52: error: Unsupported target for indexed assignment ("Callable[[int, int, int], Bitmap]")
adafruit_imageload/pnm/pgm/binary.py:52: error: "Set[int]" has no attribute "index"
adafruit_imageload/pnm/pgm/binary.py:53: error: Incompatible return value type (got "Tuple[Optional[Callable[[int, int, int], Bitmap]], Optional[Callable[[int], Palette]]]", expected "Tuple[Optional[Bitmap], Optional[Palette]]")
adafruit_imageload/pnm/pgm/ascii.py:53: error: Incompatible types in assignment (expression has type "List[int]", variable has type "Set[int]")
adafruit_imageload/pnm/pgm/ascii.py:64: error: Unsupported target for indexed assignment ("Callable[[int, int, int], Bitmap]")
adafruit_imageload/pnm/pgm/ascii.py:64: error: "Set[int]" has no attribute "index"
adafruit_imageload/pnm/pgm/ascii.py:65: error: Incompatible return value type (got "Tuple[Optional[Callable[[int, int, int], Bitmap]], Optional[Callable[[int], Palette]]]", expected "Tuple[Optional[Bitmap], Optional[Palette]]")
adafruit_imageload/bmp/indexed.py:30: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[Bitmap, BinaryIO, int, int, bool, bool, bool], None]")
adafruit_imageload/bmp/indexed.py:66: error: Unsupported target for indexed assignment ("Callable[[int], Palette]")
adafruit_imageload/bmp/indexed.py:103: error: Argument 1 to "readinto" has incompatible type "Callable[[int, int, int], Bitmap]"; expected "Bitmap"
adafruit_imageload/bmp/indexed.py:126: error: Argument "bitmap" to "decode_rle" has incompatible type "Callable[[int, int, int], Bitmap]"; expected "Bitmap"
adafruit_imageload/bmp/indexed.py:133: error: Incompatible return value type (got "Tuple[Optional[Callable[[int, int, int], Bitmap]], Optional[Callable[[int], Palette]]]", expected "Tuple[Bitmap, Optional[Palette]]")
adafruit_imageload/pnm/__init__.py:95: error: "None" not callable
adafruit_imageload/pnm/__init__.py:98: error: Unsupported target for indexed assignment ("Callable[[int], Palette]")
adafruit_imageload/pnm/__init__.py:106: error: Argument "bitmap" to "load" has incompatible type "Optional[Callable[[int, int, int], Bitmap]]"; expected "Bitmap"
adafruit_imageload/pnm/__init__.py:107: error: Argument "palette" to "load" has incompatible type "Optional[Callable[[int], Palette]]"; expected "Optional[Palette]"
adafruit_imageload/pnm/__init__.py:116: error: Argument "bitmap" to "load" has incompatible type "Optional[Callable[[int, int, int], Bitmap]]"; expected "Bitmap"
adafruit_imageload/pnm/__init__.py:117: error: Argument "palette" to "load" has incompatible type "Optional[Callable[[int], Palette]]"; expected "Optional[Palette]"
adafruit_imageload/__init__.py:78: error: Incompatible return value type (got "Tuple[Optional[Bitmap], Optional[Palette]]", expected "Tuple[Bitmap, Optional[Palette]]")
adafruit_imageload/__init__.py:82: error: Argument "bitmap" to "load" has incompatible type "Optional[Callable[[int, int, int], Bitmap]]"; expected "Callable[[int, int, int], Bitmap]"
Found 29 errors in 8 files (checked 15 source files)

@kattni kattni requested review from FoamyGuy, tekktrik and a team May 3, 2022 19:22
Copy link
Contributor

@kattni kattni left a comment

Choose a reason for hiding this comment

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

Thanks for all the work that went into this! Couple of simple change suggestions below.

I'll let one of the other folks check this out for type hint content.

@tekktrik tekktrik linked an issue May 3, 2022 that may be closed by this pull request
24 tasks
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

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

There was a lot to this one, thank you so much for tackling this @matt-land

Types all look good to me and I tested all examples successfully on PyPortal 7.3.0-beta.0

@FoamyGuy FoamyGuy merged commit 154bcae into adafruit:main May 9, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request May 10, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_BNO055 to 5.4.1 from 5.4.0:
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.

Updating https://github.com/adafruit/Adafruit_CircuitPython_RFM9x to 2.2.4 from 2.2.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_RFM9x#73 from jcerise/65/missing_type_annotations
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad to 1.16.1 from 1.16.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#60 from matt-land/add-typing

Updating https://github.com/adafruit/Adafruit_CircuitPython_JWT to 1.2.6 from 1.2.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_JWT#11 from ktkinsey37/typing
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_PIOASM to 0.7.2 from 0.7.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#47 from jepler/example-updates-background
  > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#46 from jepler/neopixel-match-core
  > Merge pull request adafruit/Adafruit_CircuitPython_PIOASM#45 from jepler/background-morse
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.

Missing Type Annotations
3 participants