Skip to content

Commit

Permalink
Fix ruff issues
Browse files Browse the repository at this point in the history
Runs `ruff format .` on the workspace.

Signed-off-by: Michael Kubacki <[email protected]>
  • Loading branch information
makubacki authored and Javagedes committed Oct 1, 2024
1 parent 9637c6b commit 61910c2
Show file tree
Hide file tree
Showing 101 changed files with 5,897 additions and 4,721 deletions.
21 changes: 12 additions & 9 deletions BasicDevTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ def TestFilenameLowercase(apath):


def PackageAndModuleValidCharacters(apath):
''' check pep8 recommendations for package and module names'''
"""check pep8 recommendations for package and module names"""

match = re.match('^[a-z0-9_/.]+$', apath.replace("\\", "/"))
match = re.match("^[a-z0-9_/.]+$", apath.replace("\\", "/"))
if match is None:
logging.critical(
f"PackageAndModuleValidCharacters failure: package or module name {apath} has something invalid")
f"PackageAndModuleValidCharacters failure: package or module name {apath} has something invalid"
)
return False
return True

Expand All @@ -55,7 +56,9 @@ def TestNoSpaces(apath):


def TestRequiredLicense(apath):
licenses = ["SPDX-License-Identifier: BSD-2-Clause-Patent", ]
licenses = [
"SPDX-License-Identifier: BSD-2-Clause-Patent",
]
try:
with open(apath, "rb") as f_obj:
contents = f_obj.read().decode()
Expand All @@ -79,15 +82,15 @@ def TestRequiredLicense(apath):
error = 0
for a in py_files:
aRelativePath = os.path.relpath(a, os.getcwd())
if (not TestEncodingOk(a, "ascii")):
if not TestEncodingOk(a, "ascii"):
error += 1
if (not TestFilenameLowercase(aRelativePath)):
if not TestFilenameLowercase(aRelativePath):
error += 1
if (not TestNoSpaces(aRelativePath)):
if not TestNoSpaces(aRelativePath):
error += 1
if (not TestRequiredLicense(a)):
if not TestRequiredLicense(a):
error += 1
if (not PackageAndModuleValidCharacters(aRelativePath)): # use relative path so only test within package
if not PackageAndModuleValidCharacters(aRelativePath): # use relative path so only test within package
error += 1

logging.critical(f"Found {error} error(s) in {len(py_files)} file(s)")
Expand Down
2 changes: 1 addition & 1 deletion ConfirmVersionAndTag.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

p = os.path.join(os.getcwd(), "dist")
whl_files = glob.glob(os.path.join(p, "*.whl"))
if (len(whl_files) != 1):
if len(whl_files) != 1:
for filename in whl_files:
print(filename)
raise Exception("Too many wheel files")
Expand Down
5 changes: 3 additions & 2 deletions docs/user/gen_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Used in conjunction with mkdocs to generate static markdown files for each
file inside the edk2toollib package for ReadTheDocs hosting.
"""

import glob
import os

Expand Down Expand Up @@ -37,7 +38,7 @@ def main():

filename = f"api{os.sep}{file_path}"
with mkdocs_gen_files.open(filename, "w") as f:
ff = file_path.replace(os.sep, '.').replace('.md', '')
ff = file_path.replace(os.sep, ".").replace(".md", "")
ff = f"edk2toollib.{ff}"
print(f"::: {ff}", file=f)
print(" handler: python", file=f)
Expand All @@ -51,7 +52,7 @@ def main():
print(" show_source: False", file=f)

# Point the "Edit on Github" button in the docs to point at the source code
edit_path = os.path.join('..', 'edk2toollib', edit_path)
edit_path = os.path.join("..", "edk2toollib", edit_path)
mkdocs_gen_files.set_edit_path(filename, edit_path)

with mkdocs_gen_files.open("api/.pages", "w") as f:
Expand Down
Loading

0 comments on commit 61910c2

Please sign in to comment.