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

Change qBittorrent lib to qbittorrentapi #113394

Merged
merged 16 commits into from
Jun 10, 2024

Conversation

Sebclem
Copy link
Contributor

@Sebclem Sebclem commented Mar 14, 2024

Proposed change

python-qbittorrent python lib seams to not be actively maintained anymore.
This change aim to remove this lib and use a more actively maintained one: qbittorent-api
Github project: https://github.com/rmartin16/qbittorrent-api
PyPi: https://pypi.org/project/qbittorrent-api/
Doc: https://qbittorrent-api.readthedocs.io/en/latest/
This will also unlock #107637 as the implementation in incorrect in python-qbittorrent

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @geoffreylagaisse, @finder39, mind taking a look at this pull request as it has been labeled with an integration (qbittorrent) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of qbittorrent can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign qbittorrent Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@joostlek
Copy link
Member

Please don't merge dev into your branch United there is a need to

@Sebclem
Copy link
Contributor Author

Sebclem commented Mar 14, 2024

Please don't merge dev into your branch United there is a need to

Oh sorry, didn't mean to spam

@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Mar 14, 2024
@joostlek
Copy link
Member

No problem, just letting you know :)

In the current case it doesn't really matter since the CI doesn't run automatically yet, but once you have a few PRs in, it will run the CI everytime, and whenever that's unneeded, we rather avoid that to prevent our CI from clogging up

@Sebclem
Copy link
Contributor Author

Sebclem commented Mar 14, 2024

Sorry forgot to push the tests change, test fixed.

@Sebclem
Copy link
Contributor Author

Sebclem commented Mar 18, 2024

Hey @finder39 , do you have some times to check this ?

@finder39
Copy link
Contributor

Sorry, just got back from a trip. Taking a look now!

@finder39
Copy link
Contributor

I tested locally (both as upgrade and fresh add of integration) and all seemed to work.

I notice quite a few # type: ignore comments in there. I assume these are linter or compiler complaints to ignore? Are these required or can it be done without these?

@Sebclem
Copy link
Contributor Author

Sebclem commented Mar 20, 2024

I tested locally (both as upgrade and fresh add of integration) and all seemed to work.

I notice quite a few # type: ignore comments in there. I assume these are linter or compiler complaints to ignore? Are these required or can it be done without these?

Yes the linter don't really like the typing using with this lib, and the pre-hook fail if you remove this I think. There is an issue open on the lib to fix that: rmartin16/qbittorrent-api#371 so hopefully we will be able to remove this in the future, I'll keep an eye on this

@finder39
Copy link
Contributor

Gotcha! Overall it looks good, so I'm good for this to be merged in. Definitely an upgrade since the old library hasn't been updated since early 2023

@Sebclem
Copy link
Contributor Author

Sebclem commented Mar 21, 2024

Gotcha! Overall it looks good, so I'm good for this to be merged in. Definitely an upgrade since the old library hasn't been updated since early 2023

Nice ! Waiting for a reviewer with write access for this to be merged 😉

@Sebclem
Copy link
Contributor Author

Sebclem commented Apr 4, 2024

Did I need to ping someone for this to be reviewed ? I'm not familiar with big project so just tell me.
Merge because of conflicts on test files

@finder39
Copy link
Contributor

finder39 commented Apr 4, 2024

I've already pinged someone to look earlier this week, they're just busy rn

@finder39
Copy link
Contributor

@Sebclem please update this to take #106501 into account

@Sebclem
Copy link
Contributor Author

Sebclem commented Apr 19, 2024

@Sebclem please update this to take #106501 into account

I'll update this tomorrow 👍

home-assistant[bot]

This comment was marked as outdated.

@home-assistant home-assistant bot marked this pull request as draft April 23, 2024 11:35
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

Copy link
Contributor

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

We should avoid using ignores. Why are you adding so many?

@home-assistant home-assistant bot marked this pull request as draft April 23, 2024 15:05
@Sebclem
Copy link
Contributor Author

Sebclem commented Apr 25, 2024

We should avoid using ignores. Why are you adding so many?

@edenhaus , I have removed all type: ignore by using Any typing, please tell me if this is better.
You can see the change in 0da9582

@Sebclem Sebclem force-pushed the feature/qbittorent_lib_change branch from d83eeff to 0da9582 Compare April 25, 2024 12:04
@Sebclem Sebclem marked this pull request as ready for review April 29, 2024 08:44
@home-assistant home-assistant bot requested a review from edenhaus April 29, 2024 08:44
homeassistant/components/qbittorrent/coordinator.py Outdated Show resolved Hide resolved
homeassistant/components/qbittorrent/helpers.py Outdated Show resolved Hide resolved
homeassistant/components/qbittorrent/helpers.py Outdated Show resolved Hide resolved
homeassistant/components/qbittorrent/helpers.py Outdated Show resolved Hide resolved
homeassistant/components/qbittorrent/helpers.py Outdated Show resolved Hide resolved
homeassistant/components/qbittorrent/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/qbittorrent/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/qbittorrent/sensor.py Outdated Show resolved Hide resolved
homeassistant/components/qbittorrent/sensor.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft May 20, 2024 09:09
@frenck frenck removed the smash Indicator this PR is close to finish for merging or closing label May 25, 2024
@Sebclem
Copy link
Contributor Author

Sebclem commented May 29, 2024

@edenhaus For all the Any type, if I try to change those to the target type, i get Type "JsonValueT" is incompatible with type "XXX" I don't know how to fix this, do you have an idea ?

@Sebclem Sebclem marked this pull request as ready for review May 29, 2024 08:15
@home-assistant home-assistant bot requested a review from edenhaus May 29, 2024 08:15
Comment on lines +122 to +123
except Forbidden403Error as err:
raise ConfigEntryNotReady("Fail to log in, banned user ?") from err
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this cause us to start a reauth flow instead? But maybe that's for a follow-up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe in another PR because I need to take a better look to the documentation, as I have seen, we need to update the Config flow to make this work right ?

Copy link
Contributor

@emontnemery emontnemery Jun 10, 2024

Choose a reason for hiding this comment

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

Yes, that's right, the config flow needs to be updated. It's fine to do that in a separate PR.

homeassistant/components/qbittorrent/helpers.py Outdated Show resolved Hide resolved
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @Sebclem

@Sebclem
Copy link
Contributor Author

Sebclem commented Jun 10, 2024

LGTM, thanks @Sebclem

Thank you for all your help, @edenhaus and you help me a lot here 🙏

@emontnemery emontnemery merged commit 80b2b05 into home-assistant:dev Jun 10, 2024
34 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants