Skip to content
Draft
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
10 changes: 6 additions & 4 deletions easybuild/base/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
import logging
import os

from typing import Optional, List

from easybuild.base import fancylogger


def get_callers_logger():
def get_callers_logger() -> Optional[logging.Logger]:
"""
Get logger defined in caller's environment
:return: logger instance (or None if none was found)
Expand Down Expand Up @@ -76,11 +78,11 @@ class LoggedException(Exception):
# must accept an argument of type string, i.e. the log message, and an optional list of formatting arguments
LOGGING_METHOD_NAME = 'error'
# list of top-level package names to use to format location info; None implies not to include location info
LOC_INFO_TOP_PKG_NAMES = []
LOC_INFO_TOP_PKG_NAMES: List[str] = []
# include location where error was raised from (enabled by default under 'python', disabled under 'python -O')
INCLUDE_LOCATION = __debug__

def __init__(self, msg, *args, **kwargs):
def __init__(self, msg: str, *args, **kwargs) -> None:
"""
Constructor.
:param msg: exception message
Expand All @@ -91,7 +93,7 @@ def __init__(self, msg, *args, **kwargs):
if args:
msg = msg % args

backtrace = []
backtrace: List[str] = []
if self.LOC_INFO_TOP_PKG_NAMES is not None:
# determine correct frame to fetch location information from
frames_up = 1
Expand Down
4 changes: 2 additions & 2 deletions easybuild/base/frozendict.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import operator
from collections.abc import Mapping
from functools import reduce
from typing import List

from easybuild.base import fancylogger

Expand Down Expand Up @@ -64,8 +65,7 @@ def keys(self):
class FrozenDictKnownKeys(FrozenDict):
"""A frozen dictionary only allowing known keys."""

# list of known keys
KNOWN_KEYS = []
KNOWN_KEYS: List[str] = []

def __init__(self, *args, **kwargs):
"""Constructor, only way to define the contents."""
Expand Down
8 changes: 5 additions & 3 deletions easybuild/base/generaloption.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from io import StringIO
from optparse import Option, OptionGroup, OptionParser, OptionValueError, Values
from optparse import SUPPRESS_HELP as nohelp # supported in optparse of python v2.4
from typing import List

from easybuild.base.fancylogger import getLogger, setroot, setLogLevel, getDetailsLogLevels
from easybuild.base.optcomplete import autocomplete, CompleterOption
Expand Down Expand Up @@ -905,9 +906,10 @@ class GeneralOption:
INTERSPERSED = True # mix args with options

CONFIGFILES_USE = True
CONFIGFILES_RAISE_MISSING = False
CONFIGFILES_INIT = [] # initial list of defaults, overwritten by go_configfiles options
CONFIGFILES_IGNORE = []
CONFIGFILES_RAISE_MISSING: bool = False
# initial list of defaults, overwritten by go_configfiles options
CONFIGFILES_INIT: List[str] = []
CONFIGFILES_IGNORE: List[str] = []
CONFIGFILES_MAIN_SECTION = 'MAIN' # sectionname that contains the non-grouped/non-prefixed options
CONFIGFILE_CASESENSITIVE = True

Expand Down
8 changes: 4 additions & 4 deletions easybuild/framework/easyconfig/easyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import re
from collections import OrderedDict
from contextlib import contextmanager
from typing import Optional
from typing import Any, Dict, Optional

import easybuild.tools.filetools as filetools
from easybuild.base import fancylogger
Expand Down Expand Up @@ -111,9 +111,9 @@
HAVE_AUTOPEP8 = False


_easyconfig_files_cache = {}
_easyconfigs_cache = {}
_path_indexes = {}
_easyconfig_files_cache: Dict[str, Any] = {}
_easyconfigs_cache: Dict[str, Any] = {}
_path_indexes: Dict[str, int] = {}


def handle_deprecated_or_replaced_easyconfig_parameters(ec_method):
Expand Down
3 changes: 2 additions & 1 deletion easybuild/framework/easyconfig/format/one.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import pprint
import re
import tempfile
from typing import List

from easybuild.base import fancylogger
from easybuild.framework.easyconfig.format.format import DEPENDENCY_PARAMETERS, EXCLUDED_KEYS_REPLACE_TEMPLATES
Expand Down Expand Up @@ -100,7 +101,7 @@ class FormatOneZero(EasyConfigFormatConfigObj):

PYHEADER_ALLOWED_BUILTINS = None # allow all
PYHEADER_MANDATORY = ['version', 'name', 'toolchain', 'homepage', 'description']
PYHEADER_BLACKLIST = []
PYHEADER_BLACKLIST: List[str] = []

def __init__(self, *args, **kwargs):
"""FormatOneZero constructor."""
Expand Down
3 changes: 2 additions & 1 deletion easybuild/framework/easyconfig/format/pyheaderconfigobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import copy
import re
import sys
from typing import List

from easybuild.base import fancylogger
from easybuild.framework.easyconfig.constants import EASYCONFIG_CONSTANTS
Expand Down Expand Up @@ -152,7 +153,7 @@ class EasyConfigFormatConfigObj(EasyConfigFormat):
- feed to ConfigObj
"""

PYHEADER_ALLOWED_BUILTINS = [] # default no builtins
PYHEADER_ALLOWED_BUILTINS: List[str] = [] # default no builtins
PYHEADER_MANDATORY = None # no defaults
PYHEADER_BLACKLIST = None # no defaults

Expand Down
1 change: 1 addition & 0 deletions easybuild/scripts/rpath_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import re
import sys


LINKER_COMMANDS = (
# binutils
'ld', 'ld.gold', 'ld.bfd',
Expand Down
4 changes: 3 additions & 1 deletion easybuild/toolchains/compiler/clang.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"""

import easybuild.tools.systemtools as systemtools
from typing import List

from easybuild.tools.toolchain.compiler import Compiler


Expand Down Expand Up @@ -104,7 +106,7 @@ class Clang(Compiler):

COMPILER_CC = 'clang'
COMPILER_CXX = 'clang++'
COMPILER_C_UNIQUE_OPTIONS = []
COMPILER_C_UNIQUE_OPTIONS: List[str] = []

LIB_MULTITHREAD = ['pthread']
LIB_MATH = ['m']
4 changes: 3 additions & 1 deletion easybuild/toolchains/compiler/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
* Kenneth Hoste (Ghent University)
"""

from typing import Dict, List, Tuple

from easybuild.tools.toolchain.compiler import Compiler


Expand All @@ -42,7 +44,7 @@ class Cuda(Compiler):
COMPILER_CUDA_MODULE_NAME = ['CUDA']
COMPILER_CUDA_FAMILY = TC_CONSTANT_CUDA

COMPILER_CUDA_UNIQUE_OPTS = {
COMPILER_CUDA_UNIQUE_OPTS: Dict[str, Tuple[List[str], str]] = {
# handle '-gencode arch=X,code=Y' nvcc options (also -arch, -code)
# -arch always needs to be specified, -code is optional (defaults to -arch if missing)
# -gencode is syntactic sugar for combining -arch/-code
Expand Down
3 changes: 2 additions & 1 deletion easybuild/toolchains/compiler/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"""

import re
from typing import List

import easybuild.tools.systemtools as systemtools
from easybuild.tools import LooseVersion
Expand Down Expand Up @@ -118,7 +119,7 @@ class Gcc(Compiler):

COMPILER_CC = 'gcc'
COMPILER_CXX = 'g++'
COMPILER_C_UNIQUE_OPTIONS = []
COMPILER_C_UNIQUE_OPTIONS: List[str] = []

COMPILER_F77 = 'gfortran'
COMPILER_F90 = 'gfortran'
Expand Down
20 changes: 11 additions & 9 deletions easybuild/tools/asyncprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import select
import subprocess
import time
from typing import Any, Optional, Tuple, Union

PIPE = subprocess.PIPE
STDOUT = subprocess.STDOUT
Expand All @@ -88,27 +89,28 @@ def __init__(self, *args, **kwargs):
kwargs['bufsize'] = 0
super().__init__(*args, **kwargs)

def recv(self, maxsize=None):
def recv(self, maxsize: Optional[int] = None) -> Optional[Union[str, bytes]]:
return self._recv('stdout', maxsize)

def recv_err(self, maxsize=None):
def recv_err(self, maxsize: Optional[int] = None) -> Optional[Union[str, bytes]]:
return self._recv('stderr', maxsize)

def send_recv(self, inp='', maxsize=None):
def send_recv(self, inp: str = '', maxsize: Optional[int] = None) -> Tuple[
Optional[int], Optional[Union[str, bytes]], Optional[Union[str, bytes]]]:
return self.send(inp), self.recv(maxsize), self.recv_err(maxsize)

def get_conn_maxsize(self, which, maxsize):
def get_conn_maxsize(self, which: str, maxsize: Optional[int]) -> Tuple[Any, int]:
if maxsize is None:
maxsize = 1024
elif maxsize < 1:
maxsize = 1
return getattr(self, which), maxsize

def _close(self, which):
def _close(self, which: str) -> None:
getattr(self, which).close()
setattr(self, which, None)

def send(self, inp):
def send(self, inp: str) -> Optional[int]:
if not self.stdin:
return None

Expand All @@ -124,7 +126,7 @@ def send(self, inp):

return written

def _recv(self, which, maxsize):
def _recv(self, which: str, maxsize: Optional[int]) -> Optional[Union[str, bytes]]:
conn, maxsize = self.get_conn_maxsize(which, maxsize)
if conn is None:
return None
Expand Down Expand Up @@ -152,7 +154,7 @@ def _recv(self, which, maxsize):
message = "Other end disconnected!"


def recv_some(p, t=.2, e=1, tr=5, stderr=0):
def recv_some(p: 'Popen', t: float = 0.2, e: int = 1, tr: int = 5, stderr: int = 0) -> bytes:
if tr < 1:
tr = 1
x = time.time() + t
Expand All @@ -175,7 +177,7 @@ def recv_some(p, t=.2, e=1, tr=5, stderr=0):
return b''.join(y)


def send_all(p, data):
def send_all(p: 'Popen', data: str) -> None:
while len(data):
sent = p.send(data)
if sent is None:
Expand Down
2 changes: 1 addition & 1 deletion easybuild/tools/build_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from easybuild.tools.version import EASYBLOCKS_VERSION, FRAMEWORK_VERSION


def get_build_stats(app, start_time, command_line):
def get_build_stats(app, start_time: float, command_line: str) -> OrderedDict:
"""
Return build statistics for this build
"""
Expand Down
Loading
Loading