Skip to content

Add type hints #45

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 7 commits into from
Oct 26, 2021
Merged

Add type hints #45

merged 7 commits into from
Oct 26, 2021

Conversation

jsymons
Copy link
Contributor

@jsymons jsymons commented Oct 26, 2021

Added type hints as per #42

Closes: #42

@jepler
Copy link
Contributor

jepler commented Oct 26, 2021

Thank you! I went ahead and marked this as hacktoberfest-accepted. However, our CI did find some problems that will need to be addressed before we can merge this. Take a look at the details of the checks and let us know if you need a hand in resolving them.

@jsymons
Copy link
Contributor Author

jsymons commented Oct 26, 2021

@jepler Should be passing now, sorry about that.

@jsymons
Copy link
Contributor Author

jsymons commented Oct 26, 2021

I've added pylint exceptions for the Pixel class that's used to type hint where a NeoPixel or DotStar device is supposed to passed through as the class is just there for type hint purposes. However on the last workflow run pylint is failing on some of the existing example code.

@jepler
Copy link
Contributor

jepler commented Oct 26, 2021

I fixed one of the diagnostics you are seeing over in #46. I think that

adafruit_espatcontrol/adafruit_espatcontrol_wifimanager.py:30:18: W0613: Unused argument 'value' (unused-argument)
adafruit_espatcontrol/adafruit_espatcontrol_wifimanager.py:29:8: R0201: Method could be a function (no-self-use)

are related to your new code.

The cause is the location of the pylint special comment:

        def fill(
            self, value: Union[int, Tuple[int, int, int]]
        ) -> Any:  # pylint: disable=unused-argument, no-self-use

After black decides to flow the parameter list onto multiple lines, it becomes necessary to move the # pylint comment to just after the opening ( of the parameter list, otherwise it doesn't work as desired.

@jsymons
Copy link
Contributor Author

jsymons commented Oct 26, 2021

Yeah I understand why it's causing the error, just not sure why it's passing when the pre-commit hooks run locally. Should be resolved now.

Copy link
Contributor

@jepler jepler left a comment

Choose a reason for hiding this comment

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

Thank you for working through the bumps on this!

@jepler jepler merged commit 20b995c into adafruit:main Oct 26, 2021
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 29, 2021
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADS1x15 to 2.2.9 from 2.2.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADS1x15#73 from tekktrik/feature/add-typing
  > add docs link to readme
  > Globally disabled consider-using-f-string pylint check
  > Moved default branch to main
  > Moved CI to Python 3.7
  > Added help text and problem matcher
  > Added pull request template
  > "Increase duplicate code check threshold "

Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP_ATcontrol to 0.5.8 from 0.5.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP_ATcontrol#44 from PontusO/revert-41-main
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP_ATcontrol#45 from jsymons/typing
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP_ATcontrol#46 from adafruit/not-using-with
  > add docs link to readme
  > Globally disabled consider-using-f-string pylint check

Updating https://github.com/adafruit/Adafruit_CircuitPython_GPS to 3.9.4 from 3.9.3:
  > Merge pull request adafruit/Adafruit_CircuitPython_GPS#69 from theendlessriver13/add-tests
  > Merge pull request adafruit/Adafruit_CircuitPython_GPS#70 from theendlessriver13/fix-byte-indexing

Updating https://github.com/adafruit/Adafruit_CircuitPython_PCF8523 to 1.5.6 from 1.5.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_PCF8523#24 from tekktrik/feature/add-typing
  > add docs link to readme
  > Globally disabled consider-using-f-string pylint check
  > Moved default branch to main
  > Moved CI to Python 3.7
  > Added help text and problem matcher
  > Added pull request template

Updating https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT to 2.4.1 from 2.4.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_AzureIoT#34 from ronnie-llamado/feature/add-type-annotations
  > add docs link to readme
  > Globally disabled consider-using-f-string pylint check
  > Moved default branch to main
  > Moved CI to Python 3.7
  > Added help text and problem matcher
  > Added pull request template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing Type Annotations
2 participants