Skip to content

Commit 3f25cd5

Browse files
committed
lint with pre-commit and ruff
1 parent 38db39e commit 3f25cd5

File tree

11 files changed

+316
-329
lines changed

11 files changed

+316
-329
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The Action aims to validate the metadata of add-ons submitted to
1313
* The `*.nvda-addon` file can be downloaded
1414
* The Sha256 of the downloaded `*.nvda-addon` file matches.
1515
* Check data matches the addon's manifest file.
16-
* The manifest exists in the downloaded `*.nvda-addon` file and can be loaded by the `AddonManifest` class.
16+
* The manifest exists in the downloaded `*.nvda-addon` file and can be loaded by the `AddonManifest` class.
1717
* The submission addonName matches the manifest summary field
1818
* The submission description matches the manifest description field
1919
* The homepage URL matches the manifest URL field

_tests/test_createJson.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@
1111
from _validate import (
1212
createJson,
1313
addonManifest,
14-
manifestLoader
14+
manifestLoader,
1515
)
1616

1717
TOP_DIR = os.path.abspath(os.path.dirname(__file__))
1818
SOURCE_DIR = os.path.dirname(TOP_DIR)
19-
INPUT_DATA_PATH = os.path.join(SOURCE_DIR, '_tests', 'testData')
19+
INPUT_DATA_PATH = os.path.join(SOURCE_DIR, "_tests", "testData")
2020
VALID_JSON = os.path.join(
2121
INPUT_DATA_PATH,
2222
"addons",
2323
"fake",
24-
"13.0.0.json"
24+
"13.0.0.json",
2525
) # json file available in testData/fake
26-
ADDON_PACKAGE = os.path.join(INPUT_DATA_PATH, 'fake.nvda-addon')
27-
MANIFEST_FILE = os.path.join(INPUT_DATA_PATH, 'manifest.ini')
26+
ADDON_PACKAGE = os.path.join(INPUT_DATA_PATH, "fake.nvda-addon")
27+
MANIFEST_FILE = os.path.join(INPUT_DATA_PATH, "manifest.ini")
2828
ADDON_CHANNEL = "testChannel"
2929
ADDON_PUBLISHER = "testPublisher"
3030
ADDON_SOURCE_URL = "https://example.com/"
3131

32-
OUTPUT_DATA_PATH = os.path.join(SOURCE_DIR, '_tests', 'testOutput')
32+
OUTPUT_DATA_PATH = os.path.join(SOURCE_DIR, "_tests", "testOutput")
3333

3434

3535
def getAddonManifest():
@@ -39,10 +39,11 @@ def getAddonManifest():
3939

4040

4141
class IntegrationTestCreateJson(unittest.TestCase):
42-
""" Integration tests.
42+
"""Integration tests.
4343
- The JSON file is created (written to the filesystem).
4444
- The output is then loaded and checked for correctness.
4545
"""
46+
4647
def setUp(self):
4748
self.outputDir = os.path.join(OUTPUT_DATA_PATH, "createJsonOutput")
4849
self.maxDiff = None # Permit unittest.TestCase (base class) to calculate diffs of any lengths.
@@ -68,12 +69,11 @@ def test_contentsMatchesExampleFile(self):
6869
actualJsonPath = os.path.join(self.outputDir, "fake", "13.0.0.json")
6970
self.assertTrue(
7071
os.path.isfile(actualJsonPath),
71-
f"Failed to create json file: {actualJsonPath}"
72+
f"Failed to create json file: {actualJsonPath}",
7273
)
7374
self._assertJsonFilesEqual(actualJsonPath=actualJsonPath, expectedJsonPath=VALID_JSON)
7475

7576
def _assertJsonFilesEqual(self, actualJsonPath: str, expectedJsonPath: str):
76-
7777
# Not equal, how are they different?
7878
with open(VALID_JSON, encoding="utf-8") as expectedFile:
7979
expectedJson = json.load(expectedFile)
@@ -99,17 +99,17 @@ def test_validVersion(self):
9999
"major": 1,
100100
"minor": 2,
101101
"patch": 0,
102-
}
102+
},
103103
},
104-
parentDir=self.outputDir
104+
parentDir=self.outputDir,
105105
)
106106

107107
dir, filename = os.path.split(outputFilePath)
108108
self.assertTrue(os.path.isdir(dir), msg="Directory must exist.")
109109
self.assertEqual(
110110
filename,
111111
"1.2.0.json",
112-
msg="Name of the output file should be named based on version number"
112+
msg="Name of the output file should be named based on version number",
113113
)
114114

115115

_tests/test_majorMinorPatch.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99

1010
class Test_getVersionNumber(unittest.TestCase):
1111
def test_tripleDigitVersion_isValid(self):
12-
""" Canonical version (major, minor, patch) expected.
13-
"""
12+
"""Canonical version (major, minor, patch) expected."""
1413
versionNumber = MajorMinorPatch.getFromStr("1.2.3")
1514
self.assertEqual(versionNumber.major, 1)
1615
self.assertEqual(versionNumber.minor, 2)
1716
self.assertEqual(versionNumber.patch, 3)
1817

1918
def test_doubleDigitVersion_isValid(self):
20-
"""patch is optional, assumed to be zero.
21-
"""
19+
"""patch is optional, assumed to be zero."""
2220
versionNumber = MajorMinorPatch.getFromStr("1.02")
2321
self.assertEqual(versionNumber.major, 1)
2422
self.assertEqual(versionNumber.minor, 2)
@@ -35,5 +33,6 @@ def test_tooManyValues_raises(self):
3533
def test_versionWithNonDigit(self):
3634
with self.assertRaises(
3735
ValueError,
38-
msg="Non-digit chars in version number expected as an error."):
36+
msg="Non-digit chars in version number expected as an error.",
37+
):
3938
MajorMinorPatch.getFromStr("1.2.3a")

0 commit comments

Comments
 (0)