Skip to content

Commit ff20316

Browse files
committed
GitHub Action to lint Python code
1 parent 7d76a23 commit ff20316

6 files changed

+19
-10
lines changed

.github/workflows/lint_python.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# https://docs.github.com/en/actions
2+
# https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-python
3+
# https://docs.astral.sh/ruff
4+
name: lint_python
5+
on: [pull_request, push]
6+
jobs:
7+
lint_python:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: astral-sh/ruff-action@v3

googletest/test/googletest-filter-unittest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ def testShardStatusFileIsCreatedWithListTests(self):
695695

696696
def testDisabledBanner(self):
697697
"""Tests that the disabled banner prints only tests that match filter."""
698-
make_filter = lambda s: ['--%s=%s' % (FILTER_FLAG, s)]
698+
make_filter = lambda s: ['--%s=%s' % (FILTER_FLAG, s)] # noqa: E731
699699

700700
banners = RunAndExtractDisabledBannerList(make_filter('*'))
701701
self.AssertSetEqual(

googletest/test/googletest-shuffle-test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def GetTestCases(tests):
119119
test_cases = []
120120
for test in tests:
121121
test_case = test.split('.')[0]
122-
if not test_case in test_cases:
122+
if test_case not in test_cases:
123123
test_cases.append(test_case)
124124

125125
return test_cases

googletest/test/gtest_test_utils.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,18 @@
3131
# Suppresses the 'Import not at the top of the file' lint complaint.
3232
# pylint: disable=g-import-not-at-top
3333

34+
import atexit
3435
import os
36+
import shutil
3537
import subprocess
3638
import sys
39+
import tempfile
40+
import unittest as _test_module
3741

3842
IS_WINDOWS = os.name == 'nt'
3943
IS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0]
4044
IS_OS2 = os.name == 'os2'
4145

42-
import atexit
43-
import shutil
44-
import tempfile
45-
import unittest as _test_module
46-
# pylint: enable=g-import-not-at-top
47-
4846
GTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT'
4947

5048
# The environment variable for specifying the path to the premature-exit file.

googletest/test/gtest_xml_outfiles_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"""Unit test for the gtest_xml_output module."""
3333

3434
import os
35-
from xml.dom import minidom, Node
35+
from xml.dom import minidom
3636
from googletest.test import gtest_test_utils
3737
from googletest.test import gtest_xml_test_utils
3838

googletest/test/gtest_xml_test_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"""Unit test utilities for gtest_xml_output"""
3131

3232
import re
33-
from xml.dom import minidom, Node
33+
from xml.dom import Node
3434
from googletest.test import gtest_test_utils
3535

3636
GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml'

0 commit comments

Comments
 (0)