Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Action to lint Python code #4693

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions .github/workflows/lint_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# https://docs.github.com/en/actions
# https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-python
# https://docs.astral.sh/ruff
name: lint_python
on: [pull_request, push]
jobs:
lint_python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
2 changes: 1 addition & 1 deletion googletest/test/googletest-filter-unittest.py
Original file line number Diff line number Diff line change
@@ -695,7 +695,7 @@ def testShardStatusFileIsCreatedWithListTests(self):

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

banners = RunAndExtractDisabledBannerList(make_filter('*'))
self.AssertSetEqual(
2 changes: 1 addition & 1 deletion googletest/test/googletest-shuffle-test.py
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ def GetTestCases(tests):
test_cases = []
for test in tests:
test_case = test.split('.')[0]
if not test_case in test_cases:
if test_case not in test_cases:
test_cases.append(test_case)

return test_cases
10 changes: 4 additions & 6 deletions googletest/test/gtest_test_utils.py
Original file line number Diff line number Diff line change
@@ -31,20 +31,18 @@
# Suppresses the 'Import not at the top of the file' lint complaint.
# pylint: disable=g-import-not-at-top

import atexit
import os
import shutil
import subprocess
import sys
import tempfile
import unittest as _test_module

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

import atexit
import shutil
import tempfile
import unittest as _test_module
# pylint: enable=g-import-not-at-top

GTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT'

# The environment variable for specifying the path to the premature-exit file.
2 changes: 1 addition & 1 deletion googletest/test/gtest_xml_outfiles_test.py
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@
"""Unit test for the gtest_xml_output module."""

import os
from xml.dom import minidom, Node
from xml.dom import minidom
from googletest.test import gtest_test_utils
from googletest.test import gtest_xml_test_utils

2 changes: 1 addition & 1 deletion googletest/test/gtest_xml_test_utils.py
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@
"""Unit test utilities for gtest_xml_output"""

import re
from xml.dom import minidom, Node
from xml.dom import Node
from googletest.test import gtest_test_utils

GTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml'