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 14, 2023
1 parent 5a988e6 commit 576dc8b
Show file tree
Hide file tree
Showing 45 changed files with 4,686 additions and 6,399 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
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 576dc8b

Please sign in to comment.