Skip to content
This repository was archived by the owner on Dec 5, 2025. It is now read-only.

Commit c5b0d17

Browse files
authored
[doc] Add sphinx-autodoc-typehints to use Python 3 annotations for documenting argument types (#94)
1 parent f5ee777 commit c5b0d17

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ test.py
1212
examples/*.json
1313
examples/*.pdf
1414
docs/_build
15-
Pipfile*
15+
Pipfile*
16+
.mypy_cache/

docs/conf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,12 @@
3434
# Add any Sphinx extension module names here, as strings. They can be
3535
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3636
# ones.
37-
extensions = ["sphinx.ext.autodoc", "sphinx.ext.inheritance_diagram", "autoapi.sphinx"]
37+
extensions = [
38+
"sphinx.ext.autodoc",
39+
"sphinx.ext.inheritance_diagram",
40+
"autoapi.sphinx",
41+
"sphinx_autodoc_typehints",
42+
]
3843

3944
# Add any paths that contain templates here, relative to this directory.
4045
templates_path = ["_templates"]

docs/requirements.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
autoapi>=2.0.1
1+
autoapi>=2.0.1
2+
sphinx_rtd_theme>=0.4.3
3+
sphinx-autodoc-typehints>=1.10.3

pycti/connector/opencti_connector_helper.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,21 @@
88
import uuid
99
import os
1010

11-
from typing import Callable, Dict, List, Union
11+
from typing import Callable, Dict, List, Optional, Union
1212
from pika.exceptions import UnroutableError, NackError
1313
from pycti.api.opencti_api_client import OpenCTIApiClient
1414
from pycti.connector.opencti_connector import OpenCTIConnector
1515

1616

1717
def get_config_variable(
18-
env_var: str, yaml_path: str, config={}, isNumber=False
19-
) -> Union[str, int]:
18+
env_var: str, yaml_path: str, config: Dict = {}, isNumber: Optional[bool] = False
19+
) -> Union[bool, int, None, str]:
2020
"""[summary]
2121
2222
:param env_var: environnement variable name
23-
:type env_var: str
2423
:param yaml_path: path to yaml config
25-
:type yaml_path: str
2624
:param config: client config dict, defaults to {}
27-
:type config: dict, optional
2825
:param isNumber: specify if the variable is a number, defaults to False
29-
:type isNumber: bool, optional
30-
:return: either a str or a int variable value
31-
:rtype: str or int
3226
"""
3327

3428
if os.getenv(env_var) is not None:

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,8 @@ def run(self):
6262
"python-magic-bin==0.4.14;sys.platform=='win32'",
6363
],
6464
cmdclass={"verify": VerifyVersionCommand},
65-
extras_require={"dev": ["black", "wheel"]}, # Optional
65+
extras_require={
66+
"dev": ["black", "wheel",],
67+
"doc": ["autoapi", "sphinx_rtd_theme", "sphinx-autodoc-typehints"],
68+
}, # Optional
6669
)

0 commit comments

Comments
 (0)