Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.10 fix latest mypy new errors #169

Merged
merged 1 commit into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/fab/build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion source/fab/steps/analyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions source/fab/steps/archive_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion source/fab/steps/c_pragma_injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions source/fab/steps/compile_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`.
Expand Down
9 changes: 5 additions & 4 deletions source/fab/steps/compile_fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`.
Expand Down Expand Up @@ -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`.

Expand Down
8 changes: 4 additions & 4 deletions source/fab/steps/grab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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`.
Expand Down
8 changes: 4 additions & 4 deletions source/fab/steps/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'.
Expand Down Expand Up @@ -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:

Expand Down
8 changes: 4 additions & 4 deletions source/fab/steps/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down