#5359 Make pagure use isort for sorting the imports in its files
Merged by ngompa. Opened by pingou.
isort  into  master

Download 5359.patch
no initial comment

4 new commits added

  • Install isort in the container environments
  • Make style check happy once and for all
  • Make isort part of the test suite
  • Run isort on the pagure code
06:46:05  ________________________ TestStyle.test_code_with_isort ________________________
06:46:05  [gw3] linux -- Python 3.6.8 /usr/libexec/platform-python
06:46:05  
06:46:05  self = <tests.test_style.TestStyle testMethod=test_code_with_isort>
06:46:05  
06:46:05      def test_code_with_isort(self):
06:46:05          """Enforce isort compliance on the codebase.
06:46:05      
06:46:05              This test runs isort on the code, and will fail if it returns a
06:46:05              non-zero exit code.
06:46:05              If isort is not installed, this test auto-skips.
06:46:05              """
06:46:05          try:
06:46:05              import isort
06:46:05          except ImportError as e:
06:46:05              raise unittest.SkipTest(
06:46:05                  "isort is not installed, skipping isort style check..."
06:46:05              )
06:46:05          # We ignore the hooks files that have a bunch of symlink
06:46:05          isort_command = [
06:46:05              sys.executable,
06:46:05              "-m",
06:46:05              "isort",
06:46:05              "-v",
06:46:05              "--profile",
06:46:05              "black",
06:46:05              "-s",
06:46:05              os.path.join(REPO_PATH, "hooks/files"),
06:46:05              "-l",
06:46:05              "79",
06:46:05              REPO_PATH,
06:46:05          ]
06:46:05      
06:46:05          # check if we have an old isort or not
06:46:05          import isort
06:46:05      
06:46:05          print(" ".join(isort_command))
06:46:05          proc = subprocess.Popen(
06:46:05              isort_command, stdout=subprocess.PIPE, cwd=REPO_PATH
06:46:05          )
06:46:05          stdout, stderr = proc.communicate()
06:46:05          print("stdout: ")
06:46:05          print(stdout.decode("utf-8")) if stdout else ""
06:46:05          print("stderr: ")
06:46:05          print(stderr.decode("utf-8")) if stderr else ""
06:46:05      
06:46:05  >       self.assertEqual(proc.returncode, 0)
06:46:05  E       AssertionError: 2 != 0
06:46:05  
06:46:05  tests/test_style.py:163: AssertionError
06:46:05  ----------------------------- Captured stdout call -----------------------------
06:46:05  /usr/libexec/platform-python -m isort -v --profile black -s /pagure/pagure/hooks/files -l 79 /pagure/pagure
06:46:05  stdout: 
06:46:05  stderr: 

rebased onto fbe023dd76e529469b296fcbdcae21d533b69c18

rebased onto db5b769184f081d4320851e1507306f281e0aff2

rebased onto dd8c24ff556ea0b6cfc04072eed75ed028134f03

Looks like the version of isort present on CentOS 8 is too old, so I'm dropping the isort test in that environment

Looks like the version of isort present on CentOS 8 is too old, so I'm dropping the isort test in that environment

Once the test environment stops being completely broken, we can add CentOS Stream 9 to the matrix. :100:

pretty please pagure-ci rebuild

Pull-Request has been merged by ngompa

Metadata