Skip to content

Commit 507a3dd

Browse files
committed
refactor: removed format string by test_basic.py
1 parent 513b274 commit 507a3dd

20 files changed

+30
-43
lines changed

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ jobs:
1919
pip install ruff black
2020
2121
- name: Run lint script
22-
run: bash scripts/lint.sh
22+
run: bash scripts/lint.sh

.mariadb/my.cnf

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ loose_file_key_management_filename = /opt/key_file/no_encryption_key.key
2020
# file_key_management_encryption_algorithm=aes_ctr
2121

2222
# Set encrypt_binlog
23-
encrypt_binlog=ON
23+
encrypt_binlog=ON

.mariadb/no_encryption_key.key

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1;dda0ccb18a28b0b4c2448b5f0217a134
1+
1;dda0ccb18a28b0b4c2448b5f0217a134

.mysql/dev.mysql.com.gpg.key

-1
Original file line numberDiff line numberDiff line change
@@ -435,4 +435,3 @@ Pw1yjWJT1IhUBBgRAgAMBQJOdz3tBQkT+wG4ABIHZUdQRwABAQkQjHGNO1By4fUU
435435
mwCbBYr2+bBEn/L2BOcnw9Z/QFWuhRMAoKVgCFm5fadQ3Afi+UQlAcOphrnJ
436436
=tUml
437437
-----END PGP PUBLIC KEY BLOCK-----
438-

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ repos:
1616
- repo: https://github.com/psf/black
1717
rev: 23.7.0
1818
hooks:
19-
- id: black
19+
- id: black

CHANGELOG

+3-4
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
* PyMYSQL 0.7
8585
* Add more contributors
8686

87-
0.10 30/11/2016
87+
0.10 30/11/2016
8888
* row-events: TIME is now encoded as python.timedelta
8989
* Allow users to define ctl_connection_settings and the option to fail when table information is unavailable (#176)
9090
* Decode gtid from network packet
@@ -128,7 +128,7 @@
128128

129129
0.19 29/04/2019
130130
* Fix Insert NULL in a boolean column returns no rows #288
131-
* Added empty string support for enum
131+
* Added empty string support for enum
132132
* Fix column order
133133
* Fix float problem about time fieldtype
134134

@@ -168,7 +168,7 @@
168168
* Add support for MariaDB GTID
169169

170170
0.29 08/04/2022
171-
* Skip db name parsing if mts_accessed_dbs == 254
171+
* Skip db name parsing if mts_accessed_dbs == 254
172172

173173
0.30 28/04/2022
174174
* Fix decoding large json arrays
@@ -231,4 +231,3 @@
231231

232232
1.0.2 05/10/2023
233233
* Delete charset_list.csv and add directly in CHARSET.py
234-

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ However, please note that skipping hooks might lead to CI failures if we use the
4848

4949
---
5050

51-
That's it! With these steps, you should be well on your way to contributing to `python-mysql-replication`. We look forward to your contributions!
51+
That's it! With these steps, you should be well on your way to contributing to `python-mysql-replication`. We look forward to your contributions!

README.md

+5-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Project status
4343
================
4444

4545
The project is test with:
46-
* MySQL 5.5, 5.6 and 5.7 (v0.1 ~ v0.45)
46+
* MySQL 5.5, 5.6 and 5.7 (v0.1 ~ v0.45)
4747
* MySQL 8.0.14 (v1.0 ~)
4848
* Python 3.3, 3.4, 3.5 and 3.6 (3.2 is not supported)
4949
* PyPy (really faster than the standard Python interpreter)
@@ -296,7 +296,7 @@ Similar projects
296296
* MySQL Hadoop Applier: C++ version http://dev.mysql.com/tech-resources/articles/mysql-hadoop-applier.html
297297
* Java: https://github.com/shyiko/mysql-binlog-connector-java
298298
* GO: https://github.com/siddontang/go-mysql
299-
* PHP: Based on this this project https://github.com/krowinski/php-mysql-replication and https://github.com/fengxiangyun/mysql-replication
299+
* PHP: Based on this this project https://github.com/krowinski/php-mysql-replication and https://github.com/fengxiangyun/mysql-replication
300300
* .NET: https://github.com/SciSharp/dotnet-mysql-replication
301301
* .NET Core: https://github.com/rusuly/MySqlCdc
302302

@@ -346,14 +346,14 @@ Other contributors:
346346
* Keegan Parker: secondary database for reference schema https://github.com/kdparker
347347
* Troy J. Farrell Clear table_map if RotateEvent has timestamp of 0 https://github.com/troyjfarrell
348348
* Zhanwei Wang Fail to get table informations https://github.com/wangzw
349-
* Alexander Ignatov Fix the JSON literal
349+
* Alexander Ignatov Fix the JSON literal
350350
* Garen Chan Support PyMysql with a version greater than 0.9.3 https://github.com/garenchan
351-
* Mike Ascah: Add logic to handle inlined ints in large json documents ttps://github.com/mascah
351+
* Mike Ascah: Add logic to handle inlined ints in large json documents ttps://github.com/mascah
352352
* Hiroaki Kawai: PyMySQL 1.0 support (https://github.com/hkwi)
353353
* Dongwook Chan: Support for ZEROFILL, Correct timedelta value for negative MySQL TIME datatype, Fix parsing of row events for MySQL8 partitioned table, Parse status variables in query event, Parse status variables in query event , Fix parse errors with MariaDB (https://github.com/dongwook-chan)
354354
* Paul Vickers: Add support for specifying an end log_pos (https://github.com/paulvic)
355355
* Samira El Aabidi: Add support for MariaDB GTID (https://github.com/Samira-El)
356-
* Oliver Seemann: Handle large json, github actions,
356+
* Oliver Seemann: Handle large json, github actions,
357357
Zero-pad fixed-length binary fields (https://github.com/oseemann)
358358
* Mahadir Ahmad: Handle null json payload (https://github.com/mahadirz)
359359
* Axel Viala: Removal of Python 2.7 (https://github.com/darnuria)
@@ -376,5 +376,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
376376
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
377377
See the License for the specific language governing permissions and
378378
limitations under the License.
379-
380-

docker-compose-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ services:
8080
- -ce
8181
- |
8282
echo "wait mysql server"
83-
83+
8484
while :
8585
do
8686
if mysql -h percona-5.7 --user=root --execute "SELECT version();" 2>&1 >/dev/null && mysql -h percona-5.7-ctl --user=root --execute "SELECT version();" 2>&1 >/dev/null && mysql -h percona-8.0 --user=root --execute "SELECT version();" 2>&1 >/dev/null; then
8787
break
8888
fi
8989
sleep 1
9090
done
91-
91+
9292
echo "run pytest"
9393
pytest -k "not test_no_trailing_rotate_event and not test_end_log_pos"
9494

docs/developement.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Running mysql in docker (main):
5555
Running mysql in docker (for ctl server):
5656

5757
::
58-
58+
5959
docker run --name python-mysql-replication-tests-ctl --expose=3307 -e MYSQL_ALLOW_EMPTY_PASSWORD=true -p 3307:3307 --rm percona:latest --log-bin=mysql-bin.log --server-id 1 --binlog-format=row --gtid_mode=on --enforce-gtid-consistency=on --log_slave-updates -P 3307
6060

6161

@@ -73,4 +73,3 @@ build it using Sphinx:
7373
cd docs
7474
pip install sphinx
7575
make html
76-

docs/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,3 @@ Indices and tables
3939
* :ref:`genindex`
4040
* :ref:`modindex`
4141
* :ref:`search`
42-

examples/logstash/logstash-simple.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ input {
55
debug => true
66
}
77
}
8-
output {
8+
output {
99
stdout { debug => true debug_format => "json"}
1010
elasticsearch { embedded => true }
1111
}

pymysqlreplication/binlogstream.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ def __check_optional_meta_data(self):
563563
logging.log(
564564
logging.WARN,
565565
"""
566-
Setting The Variable Value BINLOG_ROW_METADATA = FULL, BINLOG_ROW_IMAGE = FULL.
567-
By Applying this, provide properly mapped column information on UPDATE,DELETE,INSERT.
566+
Setting The Variable Value BINLOG_ROW_METADATA = FULL, BINLOG_ROW_IMAGE = FULL.
567+
By Applying this, provide properly mapped column information on UPDATE,DELETE,INSERT.
568568
""",
569569
)
570570
else:

pymysqlreplication/constants/STATUS_VAR_KEY.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# class StatusVarsKey(IntEnum):
44
"""List of Query_event_status_vars
5-
5+
66
A status variable in query events is a sequence of status KEY-VALUE pairs.
77
The class variables enumerated below are KEYs.
88
Each KEY determines the length of corresponding VALUE.

pymysqlreplication/tests/benchmark.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ def consume_events():
3030
for binlogevent in stream:
3131
i += 1.0
3232
if i % 1000 == 0:
33-
print("%d event by seconds (%d total)" % (i / (time.clock() - start), i))
33+
print(f"{i / (time.clock()- start)} event by seconds ({i} total)")
34+
3435
stream.close()
3536

3637

pymysqlreplication/tests/binlogfilereader.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ def __repr__(self):
101101
mod = cls.__module__
102102
name = cls.__name__
103103
only = [type(x).__name__ for x in self._only_events]
104-
fmt = "<{mod}.{name}(file_path={fpath}, only_events={only})>"
105-
return fmt.format(mod=mod, name=name, fpath=self._file_path, only=only)
104+
return f"<{mod}.{name}(file_path={self._file_path}, only_events={only})>"
106105

107106

108107
# pylint: disable=too-many-instance-attributes
@@ -134,14 +133,7 @@ def __repr__(self):
134133
cls = self.__class__
135134
mod = cls.__module__
136135
name = cls.__name__
137-
fmt = "<{mod}.{name}(timestamp={ts}, event_type={et}, log_pos={pos})>"
138-
return fmt.format(
139-
mod=mod,
140-
name=name,
141-
ts=int(self.timestamp),
142-
et=self.event_type,
143-
pos=self.log_pos,
144-
)
136+
return f"<{mod}.{name}(timestamp={int(self.timestamp)}, event_type={self.event_type}, log_pos={self.log_pos})>"
145137

146138

147139
class BadMagicBytesError(Exception):

pymysqlreplication/tests/test_basic.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def test_drop_column(self):
790790
self.stream.fetchone() # insert with two values
791791
self.stream.fetchone() # insert with one value
792792
except Exception as e:
793-
self.fail("raised unexpected exception: {exception}".format(exception=e))
793+
self.fail(f"raised unexpected exception: {e}")
794794
finally:
795795
self.resetBinLog()
796796

@@ -843,7 +843,7 @@ def test_separate_ctl_settings_no_error(self):
843843
try:
844844
self.stream.fetchone()
845845
except Exception as e:
846-
self.fail("raised unexpected exception: {exception}".format(exception=e))
846+
self.fail(f"raised unexpected exception: {e}")
847847
finally:
848848
self.resetBinLog()
849849

@@ -1400,7 +1400,7 @@ def test_start_encryption_event(self):
14001400
first_line = key_file.readline()
14011401
key_version_from_key_file = int(first_line.split(";")[0])
14021402
except Exception as e:
1403-
self.fail("raised unexpected exception: {exception}".format(exception=e))
1403+
self.fail(f"raised unexpected exception: {e}")
14041404
finally:
14051405
self.resetBinLog()
14061406

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ ignore = [
66
]
77

88
[tool.ruff.per-file-ignores]
9-
"__init__.py" = ["F401"]
9+
"__init__.py" = ["F401"]

scripts/lint.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -e
44
set -x
55

66
ruff pymysqlreplication
7-
black pymysqlreplication --check
7+
black pymysqlreplication --check

test.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ ARG MARIADB_10_6
2929
ENV MARIADB_10_6 ${MARIADB_10_6}
3030

3131
ARG MARIADB_10_6_PORT
32-
ENV MARIADB_10_6_PORT ${MARIADB_10_6_PORT}
32+
ENV MARIADB_10_6_PORT ${MARIADB_10_6_PORT}

0 commit comments

Comments
 (0)