Giter Site home page Giter Site logo

Comments (1)

trickeydan avatar trickeydan commented on September 27, 2024

So, I believe that this code is actually correct.

mypy is intelligent enough to look at whether the integer for the pin number is in the Enum or not.

So if we change it so that PinNumber: TypeAlias = AnaloguePin, we actually get a large number of valid errors:

j5/boards/arduino/uno.py:55: error: Incompatible types in assignment (expression has type "Mapping[AnaloguePin, GPIOPin]", variable has type "Mapping[int, GPIOPin]")
j5/boards/arduino/uno.py:56: error: Argument 1 to "_generate_gpio_pins" of "ArduinoUno" has incompatible type "range"; expected "Iterable[AnaloguePin]"
j5/boards/arduino/uno.py:56: note: Following member(s) of "range" have conflicts:
j5/boards/arduino/uno.py:56: note:     Expected:
j5/boards/arduino/uno.py:56: note:         def __iter__(self) -> Iterator[AnaloguePin]
j5/boards/arduino/uno.py:56: note:     Got:
j5/boards/arduino/uno.py:56: note:         def __iter__(self) -> Iterator[int]
tests/boards/sr/v4/test_ruggeduino.py:121: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests/boards/arduino/test_uno.py:116: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests/boards/sb/test_arduino.py:151: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests/boards/sb/test_arduino.py:187: error: Invalid index type "Tuple[int, int]" for "UltrasoundSensors"; expected type "Tuple[AnaloguePin, AnaloguePin]"
tests/backends/hardware/j5/test_arduino.py:211: error: Argument 2 to "check_pin_modes" has incompatible type "int"; expected "AnaloguePin"
tests_hw/test_sb_arduino.py:33: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_sb_arduino.py:34: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_sb_arduino.py:40: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_sb_arduino.py:41: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_sb_arduino.py:46: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_sb_arduino.py:47: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_sb_arduino.py:49: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_sb_arduino.py:50: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_ruggeduino.py:38: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_ruggeduino.py:39: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_ruggeduino.py:45: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_ruggeduino.py:46: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_ruggeduino.py:51: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_ruggeduino.py:52: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_ruggeduino.py:54: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"
tests_hw/test_ruggeduino.py:55: error: Invalid index type "int" for "ImmutableDict[AnaloguePin, GPIOPin]"; expected type "AnaloguePin"

Therefore, I'm going to close this issue. However, if you would like to discuss further, feel free to comment or re-open :)

from j5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.