summaryrefslogtreecommitdiffstats
path: root/qa
diff options
context:
space:
mode:
authorJoris Roovers <joris.roovers@gmail.com>2022-09-05 11:09:38 +0200
committerGitHub <noreply@github.com>2022-09-05 11:09:38 +0200
commit9c7eac63ec34b96e7b1085ac47c9314d74a7d98b (patch)
tree85d77aee7b2d95dc0e1e541b70dd7f6bd69ecf4a /qa
parent120ab9f9d0977a7545a9f414e2f84e7904200eda (diff)
Pyupgrade: upgrade code to python3.6+ (#329)
Result of running pyupgrade against gitlint, targetting Python 3.6+. This mostly cleans up some unneccesary python 2 compatibility code.
Diffstat (limited to 'qa')
-rw-r--r--qa/base.py8
-rw-r--r--qa/samples/user_rules/extra/extra_rules.py2
-rw-r--r--qa/test_commits.py1
-rw-r--r--qa/test_config.py1
-rw-r--r--qa/test_contrib.py1
-rw-r--r--qa/test_gitlint.py8
-rw-r--r--qa/test_hooks.py1
-rw-r--r--qa/test_named_rules.py1
-rw-r--r--qa/test_stdin.py4
-rw-r--r--qa/test_user_defined.py1
10 files changed, 7 insertions, 21 deletions
diff --git a/qa/base.py b/qa/base.py
index 8c0567c..7a7ccd9 100644
--- a/qa/base.py
+++ b/qa/base.py
@@ -1,8 +1,6 @@
-# -*- coding: utf-8 -*-
# pylint: disable=bad-option-value,unidiomatic-typecheck,undefined-variable,no-else-return,
# pylint: disable=too-many-function-args,unexpected-keyword-arg
-import io
import os
import platform
import shutil
@@ -81,7 +79,7 @@ class BaseTestCase(TestCase):
"""Creates a file inside a passed directory. Returns filename."""
test_filename = "test-fïle-" + str(uuid4())
# pylint: disable=consider-using-with
- io.open(os.path.join(parent_dir, test_filename), "a", encoding=DEFAULT_ENCODING).close()
+ open(os.path.join(parent_dir, test_filename), "a", encoding=DEFAULT_ENCODING).close()
return test_filename
@staticmethod
@@ -134,7 +132,7 @@ class BaseTestCase(TestCase):
# Not using a context manager to avoid unnecessary indentation in test code
tmpfile, tmpfilepath = tempfile.mkstemp()
self.tmpfiles.append(tmpfilepath)
- with io.open(tmpfile, "w", encoding=DEFAULT_ENCODING) as f:
+ with open(tmpfile, "w", encoding=DEFAULT_ENCODING) as f:
f.write(content)
return tmpfilepath
@@ -162,7 +160,7 @@ class BaseTestCase(TestCase):
specified by variable_dict."""
expected_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "expected")
expected_path = os.path.join(expected_dir, filename)
- with io.open(expected_path, encoding=DEFAULT_ENCODING) as file:
+ with open(expected_path, encoding=DEFAULT_ENCODING) as file:
expected = file.read()
if variable_dict:
diff --git a/qa/samples/user_rules/extra/extra_rules.py b/qa/samples/user_rules/extra/extra_rules.py
index 2275027..cad531b 100644
--- a/qa/samples/user_rules/extra/extra_rules.py
+++ b/qa/samples/user_rules/extra/extra_rules.py
@@ -1,5 +1,3 @@
-# -*- coding: utf-8 -*-
-
from gitlint.rules import CommitRule, RuleViolation, ConfigurationRule
from gitlint.options import IntOption, StrOption, ListOption
diff --git a/qa/test_commits.py b/qa/test_commits.py
index e01b120..8581504 100644
--- a/qa/test_commits.py
+++ b/qa/test_commits.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# pylint: disable=too-many-function-args,unexpected-keyword-arg
import re
diff --git a/qa/test_config.py b/qa/test_config.py
index 31f3cec..c9ea4e7 100644
--- a/qa/test_config.py
+++ b/qa/test_config.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# pylint: disable=too-many-function-args,unexpected-keyword-arg
import re
diff --git a/qa/test_contrib.py b/qa/test_contrib.py
index f33d015..129e576 100644
--- a/qa/test_contrib.py
+++ b/qa/test_contrib.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# pylint: disable=
from qa.shell import gitlint
from qa.base import BaseTestCase
diff --git a/qa/test_gitlint.py b/qa/test_gitlint.py
index 70efa68..bad58a1 100644
--- a/qa/test_gitlint.py
+++ b/qa/test_gitlint.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# pylint: disable=too-many-function-args,unexpected-keyword-arg
-import io
import os
from qa.shell import echo, git, gitlint
from qa.base import BaseTestCase
@@ -60,7 +58,7 @@ class IntegrationTests(BaseTestCase):
self.assertEqualStdout(output, expected)
# Make a small modification to the commit and commit it using fixup commit
- with io.open(os.path.join(self.tmp_git_repo, test_filename), "a", encoding=DEFAULT_ENCODING) as fh:
+ with open(os.path.join(self.tmp_git_repo, test_filename), "a", encoding=DEFAULT_ENCODING) as fh:
fh.write("Appending söme stuff\n")
git("add", test_filename, _cwd=self.tmp_git_repo)
@@ -89,7 +87,7 @@ class IntegrationTests(BaseTestCase):
self.assertEqualStdout(output, expected)
# Make a small modification to the commit and commit it using fixup=amend commit
- with io.open(os.path.join(self.tmp_git_repo, test_filename), "a", encoding=DEFAULT_ENCODING) as fh:
+ with open(os.path.join(self.tmp_git_repo, test_filename), "a", encoding=DEFAULT_ENCODING) as fh:
fh.write("Appending söme stuff\n")
git("add", test_filename, _cwd=self.tmp_git_repo)
@@ -135,7 +133,7 @@ class IntegrationTests(BaseTestCase):
self.assertEqualStdout(output, expected)
# Make a small modification to the commit and commit it using squash commit
- with io.open(os.path.join(self.tmp_git_repo, test_filename), "a", encoding=DEFAULT_ENCODING) as fh:
+ with open(os.path.join(self.tmp_git_repo, test_filename), "a", encoding=DEFAULT_ENCODING) as fh:
# Wanted to write a unicode string, but that's obnoxious if you want to do it across Python 2 and 3.
# https://stackoverflow.com/questions/22392377/
# error-writing-a-file-with-file-write-in-python-unicodeencodeerror
diff --git a/qa/test_hooks.py b/qa/test_hooks.py
index 9c6e943..19edeb2 100644
--- a/qa/test_hooks.py
+++ b/qa/test_hooks.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# pylint: disable=too-many-function-args,unexpected-keyword-arg
import os
from qa.shell import git, gitlint
diff --git a/qa/test_named_rules.py b/qa/test_named_rules.py
index bb202e4..75cd9a1 100644
--- a/qa/test_named_rules.py
+++ b/qa/test_named_rules.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
from qa.shell import gitlint
from qa.base import BaseTestCase
diff --git a/qa/test_stdin.py b/qa/test_stdin.py
index 41210f4..8ed4cb1 100644
--- a/qa/test_stdin.py
+++ b/qa/test_stdin.py
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
# pylint: disable=too-many-function-args,unexpected-keyword-arg
-import io
import subprocess
from qa.shell import echo, gitlint
from qa.base import BaseTestCase
@@ -44,7 +42,7 @@ class StdInTests(BaseTestCase):
"""
tmp_commit_msg_file = self.create_tmpfile("WIP: STDIN ïs a file test.")
- with io.open(tmp_commit_msg_file, encoding=DEFAULT_ENCODING) as file_handle:
+ with open(tmp_commit_msg_file, encoding=DEFAULT_ENCODING) as file_handle:
# We need to use subprocess.Popen() here instead of sh because when passing a file_handle to sh, it will
# deal with reading the file itself instead of passing it on to gitlint as a STDIN. Since we're trying to
# test for the condition where stat.S_ISREG == True that won't work for us here.
diff --git a/qa/test_user_defined.py b/qa/test_user_defined.py
index d62b1c1..a003f3e 100644
--- a/qa/test_user_defined.py
+++ b/qa/test_user_defined.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
# pylint: disable=too-many-function-args,unexpected-keyword-arg
from qa.shell import gitlint
from qa.base import BaseTestCase