Skip to content
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
5 changes: 4 additions & 1 deletion .github/workflows/package-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 flake8-pyproject
python -m pip install flake8 flake8-pyproject ruff
- name: Lint with flake8
run: |
flake8 .
- name: Lint with ruff
run: |
ruff check .

test:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion src/core/bugcheck_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def UnexpectedSituation(bugcheckSrc: str, bugcheckPoint: str, explain: str):
bugcheckSrc, bugcheckPoint
)

if not (explain is None) and explain != "":
if explain is not None and explain != "":
errMsg += " "
errMsg += explain

Expand Down
22 changes: 11 additions & 11 deletions src/core/controller_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def Helper__InsertFileIntoIndex(
assert fileKey != ""
assert fileData.IsAlive()

if not (fileKey in filesByStrKeyDictionary.keys()):
if fileKey not in filesByStrKeyDictionary.keys():
filesByStrKeyDictionary[fileKey] = fileData
else:
indexItemData = filesByStrKeyDictionary[fileKey]
Expand Down Expand Up @@ -574,7 +574,7 @@ def Helper__DeleteFileIntoIndex(
assert fileKey != ""
assert fileData.IsAlive()

if not (fileKey in filesByStrKeyDictionary.keys()):
if fileKey not in filesByStrKeyDictionary.keys():
BugCheckError.FileIsNotFoundInIndex(fileKey, fileData.m_Path)

indexItemData = filesByStrKeyDictionary[fileKey]
Expand All @@ -586,14 +586,14 @@ def Helper__DeleteFileIntoIndex(
if typeOfIndexItemData == fileData:
assert indexItemData is fileData

if not (indexItemData is fileData):
if indexItemData is not fileData:
BugCheckError.FileIsNotFoundInIndex(fileKey, fileData.m_Path)

filesByStrKeyDictionary.pop(fileKey)
assert not (fileKey in filesByStrKeyDictionary.keys())
assert fileKey not in filesByStrKeyDictionary.keys()
return

if typeOfIndexItemData == list:
if typeOfIndexItemData is list:
assert type(indexItemData) is list
assert len(indexItemData) > 1

Expand Down Expand Up @@ -635,7 +635,7 @@ def Helper__InsertOptionIntoIndex(
assert type(optionsByNameDictionary) is dict
assert type(optionData) is PgCfgModel__OptionData

if not (optionData.m_Name in optionsByNameDictionary.keys()):
if optionData.m_Name not in optionsByNameDictionary.keys():
optionsByNameDictionary[optionData.m_Name] = optionData
return

Expand Down Expand Up @@ -666,7 +666,7 @@ def Helper__DeleteOptionFromIndex(
assert type(optionsByNameDictionary) is dict
assert type(optionData) is PgCfgModel__OptionData

if not (optionData.m_Name in optionsByNameDictionary.keys()):
if optionData.m_Name not in optionsByNameDictionary.keys():
BugCheckError.OptionIsNotFoundInIndex(optionData.m_Name)

data = optionsByNameDictionary[optionData.m_Name]
Expand All @@ -675,17 +675,17 @@ def Helper__DeleteOptionFromIndex(

typeOfData = type(data)

if typeOfData == PgCfgModel__OptionData:
if typeOfData is PgCfgModel__OptionData:
assert data is optionData

if not (data is optionData):
if data is not optionData:
BugCheckError.OptionIsNotFoundInIndex(optionData.m_Name)

optionsByNameDictionary.pop(optionData.m_Name)
assert not (optionData.m_Name in optionsByNameDictionary.keys())
assert optionData.m_Name not in optionsByNameDictionary.keys()
return

if typeOfData == list:
if typeOfData is list:
assert type(data) is list
assert len(data) > 1

Expand Down
4 changes: 2 additions & 2 deletions src/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ def ExtractFirstOptionFromIndexItem(

typeOfIndexItem = type(indexItem)

if typeOfIndexItem == OptionData:
if typeOfIndexItem is OptionData:
assert indexItem.m_Name == optionName
return indexItem

if typeOfIndexItem == list:
if typeOfIndexItem is list:
assert len(indexItem) > 1
assert indexItem[0] is not None
assert type(indexItem[0]) is OptionData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ def PrepareSetValue(self, ctx: OptionHandlerCtxToPrepareSetValue) -> any:

typeOfOptionValue = type(ctx.OptionValue)

if typeOfOptionValue == int:
if typeOfOptionValue is int:
return ctx.OptionValue

optionName = ctx.OptionName
assert type(optionName) is str

if typeOfOptionValue == str:
if typeOfOptionValue is str:
if not str(ctx.OptionValue).isnumeric():
RaiseError.CantConvertOptionValue(optionName, typeOfOptionValue, int)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def PrepareSetValue(self, ctx: OptionHandlerCtxToPrepareSetValue) -> any:

typeOfOptionValue = type(ctx.OptionValue)

if typeOfOptionValue != str:
if typeOfOptionValue is not str:
optionName = ctx.OptionName
assert type(optionName) is str
RaiseError.BadOptionValueType(optionName, typeOfOptionValue, str)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ def PrepareSetValue(self, ctx: OptionHandlerCtxToPrepareSetValue) -> any:

typeOfOptionValue = type(ctx.OptionValue)

if typeOfOptionValue == str:
if typeOfOptionValue is str:
result = ReadUtils.Unpack_StrList2(ctx.OptionValue)
assert result is not None
assert type(result) is list
return result
elif typeOfOptionValue == list:
elif typeOfOptionValue is list:
result: typing.List[str] = list()
index: typing.Set[str] = set()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def PrepareSetValueItem(self, ctx: OptionHandlerCtxToPrepareSetValueItem) -> any

typeOfOptionValue = type(ctx.OptionValueItem)

if typeOfOptionValue != str:
if typeOfOptionValue is not str:
optionName = ctx.OptionName
assert type(optionName) is str
RaiseError.BadOptionValueItemType(optionName, typeOfOptionValue, str)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def OptionValueToString(self, ctx: OptionHandlerCtxToWrite) -> str:

typeOfOptionValue = type(ctx.OptionValue)

if typeOfOptionValue == int:
if typeOfOptionValue is int:
return __class__.sm_Handler_For_Int.OptionValueToString(ctx)

if typeOfOptionValue == str:
if typeOfOptionValue is str:
return __class__.sm_Handler_For_Str.OptionValueToString(ctx)

if typeOfOptionValue == bool:
if typeOfOptionValue is bool:
return __class__.sm_Handler_For_Bool.OptionValueToString(ctx)

BugCheckError.UnknownOptionValueType(ctx.OptionName, typeOfOptionValue)
Expand Down
Loading