Skip to content

Commit 9642246

Browse files
committed
🎨🐛 fix and improve type anntoations
1 parent cda3005 commit 9642246

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
# Intersphinx options
8080
intersphinx_mapping = {
8181
"python": ("https://docs.python.org/3", None),
82+
"networkx": ("https://networkx.org/documentation/stable/", None),
83+
"pyvis": ("https://pyvis.readthedocs.io/en/stable/", None),
8284
# "pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
8385
# "scikit-learn": ("https://scikit-learn.org/stable/", None),
8486
# "matplotlib": ("https://matplotlib.org/stable/", None),

vuegen/config_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import logging
2+
from typing import Optional
3+
14
from . import report as r
25
from .utils import assert_enum_value, get_logger
36

@@ -6,7 +9,7 @@ class ConfigManager:
69
"""
710
Class for handling metadata of reports from YAML config file and creating report objects.
811
"""
9-
def __init__(self, logger=None):
12+
def __init__(self, logger: Optional[logging.Logger]=None):
1013
"""
1114
Initializes the ConfigManager with a logger.
1215

vuegen/utils.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -434,16 +434,18 @@ def get_basename(fname: None | str = None) -> str:
434434
- For a given filename, returns basename WITHOUT file extension
435435
- If no fname given (i.e., None) then return basename that the function is called in
436436
437-
PARAMS
438-
-----
439-
- fname (None or str): the filename to get basename of, or None
437+
Parameters
438+
----------
439+
fname: str, optional
440+
The filename to get basename from. Default is None.
440441
441-
OUTPUTS
442-
-----
443-
- basename of given filepath or the current file the function is executed
442+
Returns
443+
-------
444+
str
445+
basename of given filepath or the current file the function is executed
444446
445447
Examples
446-
-----
448+
---------
447449
1)
448450
>>> get_basename()
449451
utils
@@ -467,17 +469,18 @@ def get_time(incl_time: bool = True, incl_timezone: bool = True) -> str:
467469
Gets current date, time (optional) and timezone (optional) for file naming
468470
469471
Parameters
470-
-----
472+
----------
471473
- incl_time (bool): whether to include timestamp in the string
472474
- incl_timezone (bool): whether to include the timezone in the string
473475
474476
Returns
475-
-----
476-
- fname (str): includes date, timestamp and/or timezone
477+
-------
478+
str
479+
fname that includes date, timestamp and/or timezone
477480
connected by '_' in one string e.g. yyyyMMdd_hhmm_timezone
478481
479482
Examples
480-
-----
483+
--------
481484
1)
482485
>>> get_time()
483486
'20231019_101758_CEST'
@@ -530,13 +533,14 @@ def generate_log_filename(folder: str = "logs", suffix: str = "") -> str:
530533
Creates log file name and path
531534
532535
Parameters
533-
-----
536+
----------
534537
folder (str): name of the folder to put the log file in
535538
suffix (str): anything else you want to add to the log file name
536539
537540
Returns
538-
-----
539-
log_filepath (str): the file path to the log file
541+
-------
542+
str
543+
The file path to the log file
540544
"""
541545
# PRECONDITIONS
542546
create_folder(folder)
@@ -548,7 +552,7 @@ def generate_log_filename(folder: str = "logs", suffix: str = "") -> str:
548552
return log_filepath
549553

550554

551-
def init_log(filename: str, display: bool = False, logger_id: str | None = None):
555+
def init_log(filename: str, display: bool = False, logger_id: str | None = None) -> logging.Logger:
552556
"""
553557
- Custom python logger configuration (basicConfig())
554558
with two handlers (for stdout and for file)
@@ -557,15 +561,16 @@ def init_log(filename: str, display: bool = False, logger_id: str | None = None)
557561
display in stdout
558562
559563
Parameters
560-
-----
561-
- filename (str): filepath to log record file
564+
----------
565+
filename (str): filepath to log record file
562566
- display (bool): whether to print the logs to whatever standard output
563567
- logger_id (str): an optional identifier for yourself,
564568
if None then defaults to 'root'
565569
566570
Returns
567-
-----
568-
- logger object
571+
-------
572+
logging.Logger
573+
The logger object
569574
570575
Examples
571576
-----

0 commit comments

Comments
 (0)