diff --git a/source/fab/build_config.py b/source/fab/build_config.py index 4692c6c4..227abafa 100644 --- a/source/fab/build_config.py +++ b/source/fab/build_config.py @@ -34,7 +34,7 @@ class BuildConfig(object): """ def __init__(self, project_label: str, source_root: Optional[Path] = None, steps: Optional[List[Step]] = None, - multiprocessing: bool = True, n_procs: int = None, reuse_artefacts: bool = False, + multiprocessing: bool = True, n_procs: Optional[int] = None, reuse_artefacts: bool = False, fab_workspace: Optional[Path] = None, verbose: bool = False, prebuild_folder: Optional[Path] = None): """ :param project_label: diff --git a/source/fab/steps/analyse.py b/source/fab/steps/analyse.py index cf8e3e4d..b3001f03 100644 --- a/source/fab/steps/analyse.py +++ b/source/fab/steps/analyse.py @@ -75,7 +75,7 @@ class Analyse(Step): """ # todo: allow the user to specify a different output artefact collection name? def __init__(self, - source: ArtefactsGetter = None, + source: Optional[ArtefactsGetter] = None, root_symbol: Optional[Union[str, List[str]]] = None, # todo: iterable is more correct std: str = "f2008", special_measure_analysis_results: Optional[List[AnalysedFile]] = None, diff --git a/source/fab/steps/archive_objects.py b/source/fab/steps/archive_objects.py index ff997443..e68205b8 100644 --- a/source/fab/steps/archive_objects.py +++ b/source/fab/steps/archive_objects.py @@ -10,7 +10,7 @@ import logging from string import Template -from typing import Dict +from typing import Dict, Optional from fab.constants import OBJECT_FILES, OBJECT_ARCHIVES from fab.steps import Step @@ -67,7 +67,7 @@ class ArchiveObjects(Step): """ # todo: the output path should not be an abs fpath, it should be relative to the proj folder - def __init__(self, source: ArtefactsGetter = None, archiver='ar', + def __init__(self, source: Optional[ArtefactsGetter] = None, archiver='ar', output_fpath=None, output_collection=OBJECT_ARCHIVES, name='archive objects'): """ :param source: diff --git a/source/fab/steps/c_pragma_injector.py b/source/fab/steps/c_pragma_injector.py index 83417181..1aba6aed 100644 --- a/source/fab/steps/c_pragma_injector.py +++ b/source/fab/steps/c_pragma_injector.py @@ -31,7 +31,7 @@ class CPragmaInjector(Step): including in paths relative to the c file. """ - def __init__(self, source: ArtefactsGetter = None, output_name=None, name="c pragmas"): + def __init__(self, source: Optional[ArtefactsGetter] = None, output_name=None, name="c pragmas"): """ :param source: An :class:`~fab.artefacts.ArtefactsGetter` which give us our c files to process. diff --git a/source/fab/steps/compile_c.py b/source/fab/steps/compile_c.py index b261ccb8..8d71a5ee 100644 --- a/source/fab/steps/compile_c.py +++ b/source/fab/steps/compile_c.py @@ -10,7 +10,7 @@ import logging import os from collections import defaultdict -from typing import List, Dict +from typing import List, Dict, Optional from fab.build_config import FlagsConfig from fab.constants import OBJECT_FILES @@ -38,8 +38,8 @@ class CompileC(Step): """ # todo: tell the compiler (and other steps) which artefact name to create? - def __init__(self, compiler: str = None, common_flags: List[str] = None, path_flags: List = None, - source: ArtefactsGetter = None, name="compile c"): + def __init__(self, compiler: Optional[str] = None, common_flags: Optional[List[str]] = None, + path_flags: Optional[List] = None, source: Optional[ArtefactsGetter] = None, name="compile c"): """ :param compiler: The command line compiler to call. Defaults to `gcc -c`. diff --git a/source/fab/steps/compile_fortran.py b/source/fab/steps/compile_fortran.py index bd235d4b..8447fb90 100644 --- a/source/fab/steps/compile_fortran.py +++ b/source/fab/steps/compile_fortran.py @@ -13,7 +13,7 @@ import zlib from collections import defaultdict from pathlib import Path -from typing import List, Set, Dict, Tuple +from typing import List, Set, Dict, Tuple, Optional from fab.build_config import FlagsConfig from fab.constants import OBJECT_FILES @@ -40,8 +40,9 @@ class CompileFortran(Step): The files are compiled in multiple passes, with each pass enabling further files to be compiled in the next pass. """ - def __init__(self, compiler: str = None, common_flags: List[str] = None, path_flags: List = None, - source: ArtefactsGetter = None, two_stage_flag=None, name='compile fortran'): + def __init__(self, compiler: Optional[str] = None, common_flags: Optional[List[str]] = None, + path_flags: Optional[List] = None, source: Optional[ArtefactsGetter] = None, + two_stage_flag=None, name='compile fortran'): """ :param compiler: The command line compiler to call. Defaults to `gfortran -c`. @@ -335,7 +336,7 @@ def compile_file(self, analysed_file, flags, output_fpath): # todo: generalise this for the preprocessor, we see flags in FPP -def get_compiler(compiler: str = None) -> Tuple[str, List[str]]: +def get_compiler(compiler: Optional[str] = None) -> Tuple[str, List[str]]: """ Separate the compiler and flags from the given string (or `FC` environment variable), like `gfortran -c`. diff --git a/source/fab/steps/grab.py b/source/fab/steps/grab.py index 5f5f2bcb..151e092a 100644 --- a/source/fab/steps/grab.py +++ b/source/fab/steps/grab.py @@ -11,7 +11,7 @@ import os from abc import ABC, abstractmethod from pathlib import Path -from typing import Dict, Union +from typing import Dict, Union, Optional try: import svn # type: ignore @@ -33,7 +33,7 @@ class GrabSourceBase(Step, ABC): Unlike most steps, grab steps don't need to read or create artefact collections. """ - def __init__(self, src: str, dst: str = None, name=None): + def __init__(self, src: str, dst: Optional[str] = None, name=None): """ :param src: The source location to grab. The nature of this parameter is depends on the subclass. @@ -72,7 +72,7 @@ class GrabFolder(GrabSourceBase): """ - def __init__(self, src: Union[Path, str], dst: str = None, name=None): + def __init__(self, src: Union[Path, str], dst: Optional[str] = None, name=None): """ :param src: The source location to grab. The nature of this parameter is depends on the subclass. @@ -100,7 +100,7 @@ class GrabFcm(GrabSourceBase): Grab an FCM repo folder to the project workspace. """ - def __init__(self, src: str, dst: str = None, revision=None, name=None): + def __init__(self, src: str, dst: Optional[str] = None, revision=None, name=None): """ :param src: Such as `fcm:jules.xm_tr/src`. diff --git a/source/fab/steps/link.py b/source/fab/steps/link.py index fdea4c0c..0e7c91a6 100644 --- a/source/fab/steps/link.py +++ b/source/fab/steps/link.py @@ -11,7 +11,7 @@ import os from abc import ABC from string import Template -from typing import List +from typing import List, Optional from fab.constants import OBJECT_FILES, OBJECT_ARCHIVES, EXECUTABLES from fab.steps import Step @@ -45,7 +45,7 @@ class LinkerBase(Step, ABC): compiler steps. """ - def __init__(self, linker: str = None, flags=None, source: ArtefactsGetter = None, name='link'): + def __init__(self, linker: Optional[str] = None, flags=None, source: Optional[ArtefactsGetter] = None, name='link'): """ :param linker: E.g 'gcc' or 'ld'. @@ -107,8 +107,8 @@ class LinkSharedObject(LinkExe): We can assume the list of object files is the entire project source, compiled. """ - def __init__(self, output_fpath: str, linker: str = None, flags=None, source: ArtefactsGetter = None, - name='link shared object'): + def __init__(self, output_fpath: str, linker: Optional[str] = None, flags=None, + source: Optional[ArtefactsGetter] = None, name='link shared object'): """ Params are as for :class:`~fab.steps.link_exe.LinkerBase`, with the addition of: diff --git a/source/fab/steps/preprocess.py b/source/fab/steps/preprocess.py index f79eca71..cfa3f70b 100644 --- a/source/fab/steps/preprocess.py +++ b/source/fab/steps/preprocess.py @@ -10,7 +10,7 @@ import logging import os from pathlib import Path -from typing import List +from typing import List, Optional from fab.build_config import FlagsConfig from fab.constants import PRAGMAD_C @@ -34,9 +34,9 @@ class PreProcessor(Step): LABEL: str def __init__(self, - source: ArtefactsGetter = None, output_collection=None, output_suffix=None, - preprocessor: str = None, common_flags: List[str] = None, path_flags: List = None, - name=None): + source: Optional[ArtefactsGetter] = None, output_collection=None, output_suffix=None, + preprocessor: Optional[str] = None, common_flags: Optional[List[str]] = None, + path_flags: Optional[List] = None, name=None): """ :param source: Defines the files to preprocess. Defaults to DEFAULT_SOURCE.