koenvervloesem / bluetooth-numbers

An up-to-date listing of all the various Bluetooth Specification-related elements (Company IDs, Service UUIDs, Characteristic UUIDs and Descriptor UUIDs), that you can use in your Python projects instead of rolling your own.
https://bluetooth-numbers.readthedocs.io
MIT License
16 stars 3 forks source link

Add Reverse lookup #43

Closed vincentdavis closed 9 months ago

vincentdavis commented 9 months ago

Issue #42, reverse lookup I have implemented this as a class that initiates from the UUID dicts. I did it this way rather than writing the index to a file for two reasons; 1: it's fast enough, 2: In the future, we might want to add the ability to rebuild the index incases where the user adds custom UUIDs. Feedback appreciated. I am not very familiar with taking full advantage of pytest.

vincentdavis commented 9 months ago

Just made a few updates to fix doc test and test annotations

koenvervloesem commented 9 months ago

Do you have pre-commit installed? It catches the same errors as found by the CI here, but locally.

See https://bluetooth-numbers.readthedocs.io/en/stable/contributing.html#clone-the-repository for the installation.

vincentdavis commented 9 months ago

Do you have pre-commit installed? It catches the same errors as found by the CI here, but locally.

See https://bluetooth-numbers.readthedocs.io/en/stable/contributing.html#clone-the-repository for the installation.

I am working on that right now.

vincentdavis commented 9 months ago

@koenvervloesem Kinda struggling with the pre-commit. I have a lot of it cleaned up. I don't think I have everything installed to fully run the pre-commit and my editor, Pycharm, is not using ruff configuration correctly. It's not giving me the hints and warnings or fixing the import sorting as I expect.

I don't seem to have all the type hints correct, but again not getting clear information from Pycharm as to whats wrong.

I am kinda stuck and out of time for now.

Maybe a development requirements file would be helpful?

koenvervloesem commented 9 months ago

Thanks already for the work you did! I'll take a look at the pre-commit errors tomorrow and see what I can fix. Maybe we can also ignore some of the errors if they're too pedantic.

koenvervloesem commented 9 months ago

I added some comments, these should solve/ignore most of the errors. But have a look at the doctests too.

vincentdavis commented 9 months ago

I added some comments, these should solve/ignore most of the errors. But have a look at the doctests too.

Ok, I have cleaned up most of this, I'll finish up later today.

koenvervloesem commented 9 months ago

Ok, just one issue with the import order (see above), and the two doctest issues I reviewed, and then this looks ready to merge.

vincentdavis commented 9 months ago

I think it's ready. The interrogate pre-commit does not work for me locally. I like the idea of what it does. Maybe using Ruff's pydocstyle would be simpler and sufficient. https://docs.astral.sh/ruff/rules/#pydocstyle-d

koenvervloesem commented 9 months ago

If you click on Details next to the failing tests, there are still some issues. Could you take a look at them? Once these tests run successfully, we can merge this PR.

vincentdavis commented 9 months ago

@koenvervloesem looking at the failing doc test, not sure what I am doing wrong. Is it sensitive to whitespace (2 lines vs 1 line?

Failed example:
    rl.lookup("Power Feature", uuid_types=['characteristic'],logic="SUBSTR")
Expected:
    {Match(uuid=10853, description='Cycling Power Feature',
    uuid_type='characteristic')}
Got:
    {Match(uuid=10853, description='Cycling Power Feature', uuid_type='characteristic')}
koenvervloesem commented 9 months ago

Yes, and the solution is the # doctest: +NORMALIZE_WHITESPACE I was talking about in https://github.com/koenvervloesem/bluetooth-numbers/pull/43#discussion_r1423619840

So this example should look like:

>>> rl.lookup("Power Feature", uuid_types=['characteristic'],
... logic="SUBSTR")  # doctest: +NORMALIZE_WHITESPACE
{Match(uuid=10853, description='Cycling Power Feature',
uuid_type='characteristic')}
vincentdavis commented 9 months ago

Thanks for your patience

codecov[bot] commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (59465e8) 100.00% compared to head (05a456e) 100.00%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #43 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 9 10 +1 Lines 108 153 +45 Branches 16 39 +23 ========================================= + Hits 108 153 +45 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

koenvervloesem commented 9 months ago

Perfect! Now only the code coverage check complains, but the type checking line should be ignored. You can solve this by adding the following lines at the end of .coveragerc:


    # Assume if TYPE_CHECKING is covered
    if TYPE_CHECKING:
koenvervloesem commented 9 months ago

Thanks for patiently fixing your code to follow the project's code style!