Skip to content

Commit

Permalink
Integrate typing into source
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartin16 committed Oct 15, 2023
1 parent 5a988e6 commit f655ea7
Show file tree
Hide file tree
Showing 51 changed files with 4,745 additions and 6,442 deletions.
34 changes: 9 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-toml
- id: check-yaml
Expand All @@ -18,7 +18,7 @@ repos:
- toml

- repo: https://github.com/asottile/pyupgrade
rev: v3.13.0
rev: v3.15.0
hooks:
- id: pyupgrade
args:
Expand All @@ -36,7 +36,7 @@ repos:
- --non-cap=qBittorrent

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.291
rev: v0.0.292
hooks:
- id: ruff
args:
Expand All @@ -49,35 +49,19 @@ repos:
language_version: python3

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.6.0
hooks:
- id: mypy
files: '.*\.pyi'
files: ^src/
additional_dependencies:
- types-requests
- types-six
- packaging
args:
- --strict
- --disallow-any-unimported
- --disallow-any-expr
- --disallow-any-decorated
- --warn-unreachable
- --warn-unused-ignores
- --warn-redundant-casts
# - --disallow-any-expr
# - --disallow-any-decorated
- --strict-optional
- --show-traceback

- repo: local
hooks:
- id: stubtest
name: mypy.stubtest
language: system
entry: stubtest
args:
- qbittorrentapi
- --allowlist=tests/_resources/mypy_stubtest_allowlist.txt
pass_filenames: false
types_or:
- python
- text
files: '.*\.pyi?'
- --implicit-reexport
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Change log
==========
### vXXXX.X.XX (X xxx XXXX)
- Dropped support for legacy Python versions; Python 3.8+ is supported (#333)
- Refactored typing from stub files in to source (#345)
- Dropped support for API method arguments ``hash`` and ``hashes``; use ``torrent_hash`` and ``torrent_hashes``, respectively (#345)
- For example, replace ``client.torrents_info(hashes="...")`` with ``client.torrents_info(torrent_hashes="...")``

### v2023.9.53 (7 sept 2023)
- Advertise support for Python 3.12
- Advertise support for qBittorrent v4.5.5
Expand Down
4 changes: 2 additions & 2 deletions docs/source/apidoc/app.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Application
.. autoclass:: qbittorrentapi.app.AppAPIMixIn
:members:
:undoc-members:
:exclude-members: app, application, app_webapiVersion, app_buildInfo, app_setPreferences, app_defaultSavePath
:exclude-members: app, application, app_webapiVersion, app_buildInfo, app_setPreferences, app_defaultSavePath, app_networkInterfaceAddressList, app_networkInterfaceList
:show-inheritance:

.. autoclass:: qbittorrentapi.app.Application
:members:
:undoc-members:
:exclude-members: app, application, webapiVersion, buildInfo, setPreferences, defaultSavePath
:exclude-members: app, application, webapiVersion, buildInfo, setPreferences, defaultSavePath, networkInterfaceAddressList, networkInterfaceList

.. autoclass:: qbittorrentapi.app.ApplicationPreferencesDictionary
:members:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/apidoc/rss.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ RSS
.. autoclass:: qbittorrentapi.rss.RSSAPIMixIn
:members:
:undoc-members:
:exclude-members: rss, rss_addFolder, rss_addFeed, rss_removeItem, rss_moveItem, rss_refreshItem, rss_markAsRead, rss_setRule, rss_renameRule, rss_removeRule, rss_matchingArticles
:exclude-members: rss, rss_addFolder, rss_addFeed, rss_removeItem, rss_moveItem, rss_refreshItem, rss_markAsRead, rss_setRule, rss_renameRule, rss_removeRule, rss_matchingArticles, rss_setFeedURL
:show-inheritance:

.. autoclass:: qbittorrentapi.rss.RSS
:members:
:undoc-members:
:exclude-members: rss, addFolder, addFeed, removeItem, moveItem, refreshItem, markAsRead, setRule, renameRule, removeRule, matchingArticles
:exclude-members: rss, addFolder, addFeed, removeItem, moveItem, refreshItem, markAsRead, setRule, renameRule, removeRule, matchingArticles, setFeedURL

.. autoclass:: qbittorrentapi.rss.RSSitemsDictionary
:members:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/apidoc/torrents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Torrents
.. autoclass:: qbittorrentapi.torrents.TorrentsAPIMixIn
:members:
:undoc-members:
:exclude-members: torrents, torrent_categories, torrent_tags, torrents_pieceStates, torrents_pieceHashes, torrents_addTrackers, torrents_editTracker, torrents_removeTrackers, torrents_filePrio, torrents_renameFile, torrents_renameFolder, torrents_increasePrio, torrents_decreasePrio, torrents_topPrio, torrents_bottomPrio, torrents_downloadLimit, torrents_setDownloadLimit, torrents_setShareLimits, torrents_uploadLimit, torrents_setUploadLimit, torrents_setLocation, torrents_setCategory, torrents_setAutoManagement, torrents_toggleSequentialDownload, torrents_toggleFirstLastPiecePrio, torrents_setForceStart, torrents_setSuperSeeding, torrents_addPeers, torrents_createCategory, torrents_editCategory, torrents_removeCategories, torrents_addTags, torrents_removeTags, torrents_createTags, torrents_deleteTags
:exclude-members: torrents, torrent_categories, torrent_tags, torrents_pieceStates, torrents_pieceHashes, torrents_addTrackers, torrents_editTracker, torrents_removeTrackers, torrents_filePrio, torrents_renameFile, torrents_renameFolder, torrents_increasePrio, torrents_decreasePrio, torrents_topPrio, torrents_bottomPrio, torrents_downloadLimit, torrents_setDownloadLimit, torrents_setShareLimits, torrents_uploadLimit, torrents_setUploadLimit, torrents_setLocation, torrents_setCategory, torrents_setAutoManagement, torrents_toggleSequentialDownload, torrents_toggleFirstLastPiecePrio, torrents_setForceStart, torrents_setSuperSeeding, torrents_addPeers, torrents_createCategory, torrents_editCategory, torrents_removeCategories, torrents_addTags, torrents_removeTags, torrents_createTags, torrents_deleteTags, torrents_setDownloadPath, torrents_setSavePath
:show-inheritance:

.. autoclass:: qbittorrentapi.torrents.Torrents
:members:
:undoc-members:
:exclude-members: pieceStates, pieceHashes, addTrackers, editTracker, removeTrackers, filePrio, renameFile, renameFolder, increasePrio, decreasePrio, topPrio, bottomPrio, downloadLimit, setDownloadLimit, setShareLimits, uploadLimit, setUploadLimit, setLocation, setCategory, setAutoManagement, toggleSequentialDownload, toggleFirstLastPiecePrio, setForceStart, setSuperSeeding, addPeers, createCategory, editCategory, removeCategories, addTags, removeTags, createTags, deleteTags
:exclude-members: pieceStates, pieceHashes, addTrackers, editTracker, removeTrackers, filePrio, renameFile, renameFolder, increasePrio, decreasePrio, topPrio, bottomPrio, downloadLimit, setDownloadLimit, setShareLimits, uploadLimit, setUploadLimit, setLocation, setCategory, setAutoManagement, toggleSequentialDownload, toggleFirstLastPiecePrio, setForceStart, setSuperSeeding, addPeers, createCategory, editCategory, removeCategories, addTags, removeTags, createTags, deleteTags, setDownloadPath, setSavePath

.. autoclass:: qbittorrentapi.torrents.TorrentDictionary
:members:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/apidoc/transfer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Transfer
.. autoclass:: qbittorrentapi.transfer.Transfer
:members:
:undoc-members:
:exclude-members: toggleSpeedLimitsMode, setDownloadLimit, setUploadLimit, banPeers, speedLimitsMode, downloadLimit, uploadLimit
:exclude-members: toggleSpeedLimitsMode, setDownloadLimit, setUploadLimit, banPeers, speedLimitsMode, downloadLimit, uploadLimit, setSpeedLimitsMode

.. autoclass:: qbittorrentapi.transfer.TransferInfoDictionary
:members:
Expand Down
46 changes: 31 additions & 15 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,45 @@


# -- General configuration ---------------------------------------------------
pygments_style = "sphinx"

# warn about everything
nitpicky = True

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
# Add any Sphinx extension module names here, as strings. They can be extensions coming
# with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = [
"sphinx.ext.todo",
"sphinx.ext.githubpages",
"sphinx.ext.autodoc",
"sphinx_autodoc_typehints",
"sphinx.ext.intersphinx",
"sphinx_copybutton",
]

pygments_style = "sphinx"

# warn about everything
nitpicky = True
nitpick_ignore = [
("py:class", "JsonValueT"),
("py:class", "ListInputT"),
("py:class", "Response"),
("py:class", "Request"),
("py:class", "qbittorrentapi.request.ResponseT"),
("py:class", "qbittorrentapi.request.T"),
("py:class", "qbittorrentapi.torrents.TorrentFilesT"),
("py:obj", "qbittorrentapi._attrdict.K"),
("py:obj", "qbittorrentapi._attrdict.V"),
("py:obj", "qbittorrentapi.definitions.K"),
("py:obj", "qbittorrentapi.definitions.V"),
]

autodoc_type_aliases = {"JsonValueT": "qbittorrentapi.definitions.JsonValueT"}
add_module_names = False
autodoc_typehints_format = "short"
python_use_unqualified_type_names = True
python_use_unqualified_names = True
typehints_fully_qualified = False
typehints_use_signature = False
typehints_use_signature_return = True
typehints_document_rtype = True

source_suffix = ".rst"

# The master toctree document.
Expand Down Expand Up @@ -80,13 +103,6 @@

html_theme = "furo"

# sphinx-autoapi
# extensions.append('autoapi.extension')
# autoapi_type = 'python'
# autoapi_dirs = ['../../qbittorrentapi']
# autoapi_options = ['show-inheritance-diagram']
# autoapi_ignore = ['*decorators*', '*exceptions*']

# Add mappings
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
Expand Down
6 changes: 6 additions & 0 deletions docs/source/spelling_wordlist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Attrs
Auth
bc
boolean
bt
casted
Curran
Expand All @@ -12,10 +14,14 @@ hostname
instantiation
iterable
kwargs
MitM
namespace
namespaces
qBittorrent
pem
Reannounce
ResponseT
str
untagged
Untrusted
untrusted
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ exclude_lines = [
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]

[tool.coverage.html]
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ dev =
sphinx == 7.2.6; python_version >= "3.9"
sphinx-copybutton == 0.5.2
sphinxcontrib-spelling == 8.0.0
sphinx-autodoc-typehints == 1.24.0
tox == 4.11.3
twine == 4.0.2
types-requests == 2.31.0.5
Expand Down
Loading

0 comments on commit f655ea7

Please sign in to comment.