Resolve pylint errors in common.py

This commit is contained in:
bom 2023-04-28 14:57:19 +02:00
parent c70daa346d
commit 837b58d5b8
2 changed files with 11 additions and 10 deletions

View file

@ -27,7 +27,7 @@ pylint:
stage: lint&test stage: lint&test
script: script:
- pip install -r dev_requirements.txt - pip install -r dev_requirements.txt
- pylint -d W0511,R0903,C0301,W0614,C0114,C0115,C0116,similarities,W0719,W0702,W0702,R0913,R0902,R0914,R1732 src/main/python/ddadevops/ - pylint -d W0511,R0903,C0301,W0614,C0114,C0115,C0116,similarities,W1203,W0719,W0702,W0702,R0913,R0902,R0914,R1732 src/main/python/ddadevops/
pytest: pytest:
stage: lint&test stage: lint&test

View file

@ -1,6 +1,6 @@
import deprecation
import logging
from typing import List from typing import List
import logging
import deprecation
def filter_none(list_to_filter): def filter_none(list_to_filter):
return [x for x in list_to_filter if x is not None] return [x for x in list_to_filter if x is not None]
@ -10,7 +10,7 @@ class Validateable:
value = self.__dict__[field_name] value = self.__dict__[field_name]
if value is None or value == "": if value is None or value == "":
return [f"Field '{field_name}' must not be empty."] return [f"Field '{field_name}' must not be empty."]
else:
return [] return []
def validate(self) -> List[str]: def validate(self) -> List[str]:
@ -46,7 +46,7 @@ class Devops(Validateable):
self.stage = stage self.stage = stage
self.name = name self.name = name
self.project_root_path = project_root_path self.project_root_path = project_root_path
logging.warn(f"Set project root in DevOps {self.project_root_path}") logging.warning(f"Set project root in DevOps {self.project_root_path}")
self.module = module self.module = module
if not name: if not name:
self.name = module self.name = module
@ -56,22 +56,23 @@ class Devops(Validateable):
@deprecation.deprecated(deprecated_in="3.2") @deprecation.deprecated(deprecated_in="3.2")
# use .name instead # use .name instead
#pylint: disable=method-hidden
def name(self): def name(self):
return self.name return self.name
def build_path(self): def build_path(self):
path = [self.project_root_path, self.build_dir_name, self.name, self.module] path = [self.project_root_path, self.build_dir_name, self.name, self.module]
logging.warn(f"Set project build_path in Devops {path}") logging.warning(f"Set project build_path in Devops {path}")
return "/".join(filter_none(path)) return "/".join(filter_none(path))
def __put__(self, key, value): def __put__(self, key, value):
self.stack[key] = value self.stack[key] = value
def __get__(self, key): def __get(self, key):
return self.stack[key] return self.stack[key]
def __get_keys__(self, keys): def __get_keys__(self, keys):
result = {} result = {}
for key in keys: for key in keys:
result[key] = self.__get__(key) result[key] = self.__get(key)
return result return result