Skip to content
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

Added type annotations. #13

Merged
merged 11 commits into from Jul 30, 2023
Merged

Conversation

sdomoszlai13
Copy link
Contributor

Added requested type annotations to adafruit_ms8607.py. Please take a look, @FoamyGuy .

@sdomoszlai13
Copy link
Contributor Author

I have a problem with line 77. I need to add a tuple of objects of type Any, but can't make it work. The error now is:

File "/home/runner/work/Adafruit_CircuitPython_MS8607/Adafruit_CircuitPython_MS8607/adafruit_ms8607.py", line 77, in CV
def add_values(cls, value_tuples: Tuple[Any, ...]) -> None:
^^^
NameError: name 'Any' is not defined

Error: Process completed with exit code 2.

Related question: pre-commit doesn't give me any error on my computer. I only encounter this error after pushing to GitHub. Is it possible to get the exact same error messages locally before pushing to GitHub? Maybe I'm doing something wrong.

@FoamyGuy
Copy link
Contributor

My first guess for the error:

NameError: name 'Any' is not defined

Would be that Any was attempted to be used in a type annotation without having been imported first.

With regards to getting set up to see the same errors locally. The learn guide page here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code and the 2 pages that follow it cover the setup for pre-commit, pylint, and black which are the tools used for the actions checks that run automatically in github.

Once you get them set up locally you can run them with a command like:

pre-commit run -a

and it will do all of the checks in your local instance and output any warnings or errors.

@sdomoszlai13
Copy link
Contributor Author

Thanks for your quick reply @FoamyGuy !

Unfortunately, Any is imported and I still got the error.

Actually, I've been using pre-commit for a while and always check the files with it locally before committing. My problem is that the tests run without errors locally, so I commit, and then sometimes the 'GitHub version' of the tests throws errors, like the above one with the unknown Any NameError. I don't get this error when running pre-commit locally on my machine.

@sdomoszlai13
Copy link
Contributor Author

I'm still having problems with plain module imports (ModuleNotFound errors). Currently, I get the following output:
[INFO] This may take a few minutes...
Error: black....................................................................Failed

  • hook id: black
  • files were modified by this hook

Error: reformatted adafruit_ms8607.py

All done! ✨ 🍰 ✨
1 file reformatted, 2 files left unchanged.

reuse....................................................................Passed
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
pylint (library code)....................................................Passed
pylint (example code)....................................................Passed
pylint (test code)...................................(no files to check)Skipped
Error: Process completed with exit code 1.

And also:
Run adafruit/circuitpython-action-library-ci-failed@v1
Error: Cannot read properties of undefined (reading 'number')

I really ran out of ideas. Can you help out @FoamyGuy ? Thanks!

@FoamyGuy
Copy link
Contributor

Sorry for the delay, this one got lost for me.

Unfortunately I don't really recognize the errors you posted:

Run adafruit/circuitpython-action-library-ci-failed@v1
Error: Cannot read properties of undefined (reading 'number')

The bit further up in the output about the Black formatting is expected output though. It means that Black did some reformatting and now the resulting changes need to be committed.

I've run this locally now and will make a new commit with those changes.

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.

The latest version looks good to me after the code formatting.

Thanks for working on this @sdomoszlai13!

If you are still having issues when you run pre-commit locally you can try to get help on our discord as well.

@FoamyGuy FoamyGuy merged commit f0cdb74 into adafruit:main Jul 30, 2023
1 check passed
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jul 31, 2023
Updating https://github.com/adafruit/Adafruit_CircuitPython_MS8607 to 1.0.19 from 1.0.18:
  > Merge pull request adafruit/Adafruit_CircuitPython_MS8607#13 from sdomoszlai13/type_annotations

Updating https://github.com/adafruit/Adafruit_CircuitPython_SCD4X to 1.4.0 from 1.3.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_SCD4X#7 from KeithTheEE/add_one_shot_co2

Updating https://github.com/adafruit/Adafruit_CircuitPython_ServoKit to 1.3.15 from 1.3.14:
  > Merge pull request adafruit/Adafruit_CircuitPython_ServoKit#49 from spovlot/fix-i2c-doc

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Updated download stats for the libraries
@FoamyGuy FoamyGuy mentioned this pull request Jul 31, 2023
13 tasks
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.

None yet

2 participants