harelba / q

q - Run SQL directly on delimited files and multi-file sqlite databases
http://harelba.github.io/q/
GNU General Public License v3.0
10.15k stars 419 forks source link

Convert five assignment statements to augmented source code #287

Open elfring opened 2 years ago

elfring commented 2 years ago

:eyes: Some source code analysis tools can help to find opportunities for improving software components. :thought_balloon: I propose to increase the usage of augmented assignment statements accordingly.

diff --git a/bin/q.py b/bin/q.py
index 716e783..9ec549b 100755
--- a/bin/q.py
+++ b/bin/q.py
@@ -1102,7 +1102,7 @@ class TableColumnInferer(object):
                         len(self.header_row), self.column_count))
                 elif self.mode in ['relaxed']:
                     # in relaxed mode, add columns to fill the missing ones
-                    self.header_row = self.header_row + \
+                    self.header_row += \
                         ['c%s' % (x + len(self.header_row) + 1)
                          for x in range(self.column_count - len(self.header_row))]
             elif len(self.header_row) > self.column_count:
@@ -1442,7 +1442,7 @@ class DelimitedFileReader(object):
             else:
                 for file_name,is_first_line,col_vals in csv_reader:
                     if is_first_line:
-                        self.file_number = self.file_number + 1
+                        self.file_number += 1
                     self.lines_read += 1
                     yield file_name,self.file_number,is_first_line,col_vals
         except ColumnMaxLengthLimitExceededException as e:
@@ -2262,7 +2262,7 @@ class TableCreator(object):
         # in all non strict mode, we add dummy data to missing columns

         if actual_col_count < expected_col_count:
-            col_vals = col_vals + \
+            col_vals += \
                 [None for x in range(expected_col_count - actual_col_count)]

         # in relaxed mode, we merge all extra columns to the last column value
diff --git a/test/test_suite.py b/test/test_suite.py
index f722e8f..93c7dff 100755
--- a/test/test_suite.py
+++ b/test/test_suite.py
@@ -409,7 +409,7 @@ class SaveToSqliteTests(AbstractQTestCase):

         tables_as_str = " left join ".join(["%s/%s" % (tmpfolder,x) for x in filename_list])

-        tables_as_str = tables_as_str + ' left join %s/non_existent_table' % (tmpfolder)
+        tables_as_str += ' left join %s/non_existent_table' % (tmpfolder)

         cmd = '%s -H "select count(*) from %s" -c 1 -S %s' % (Q_EXECUTABLE,tables_as_str,output_sqlite_file)
         retcode, o, e = run_command(cmd)
@@ -5627,7 +5627,7 @@ class BenchmarkTests(AbstractQTestCase):
         def generate_q_cmd(data_filename, line_count, column_count):
             Q_BENCHMARK_ADDITIONAL_PARAMS = os.environ.get('Q_BENCHMARK_ADDITIONAL_PARAMS') or ''
             additional_params = ''
-            additional_params = additional_params + ' ' + Q_BENCHMARK_ADDITIONAL_PARAMS
+            additional_params += ' ' + Q_BENCHMARK_ADDITIONAL_PARAMS
             return '{} -d , {} "select count(*) from {}"'.format(Q_EXECUTABLE,additional_params, data_filename)
         self._perform_test_performance_matrix(Q_BENCHMARK_NAME,generate_q_cmd)