Comments (1)
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)
- Ensure arduino pins are set as outputs when changing mode HOT 2
- Allow more custom instantiations of backends HOT 1
- StringCommandComponent does not fit naming convention
- Add `morse` method for `Piezo`
- Not all USB devices have a serial number
- Show Error code specification on type: ignores
- Student Robotics 2023 Firmware HOT 1
- Add support for flashing LED state HOT 1
- Add Support for Backend Feature Flags
- SR Power Board v4 Serial Protocol: Add Support for 5V Output HOT 1
- Support silencing a buzzer where supported
- Incorrect regex for tags HOT 1
- When a board with a given serial number is not in BoardGroup, list available serials
- Replace `CommunicationError` with more specific error types HOT 2
- Ruggeduino overrides pinmodes at initialisation HOT 4
- Ruggeduino Initialisation Test is not very clear
- SRv4 Motor Board Serial Firmware Support HOT 1
- SRv4 Servo Board Serial Firmware Support
- Implement support for KCH User LEDs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from j5.