Skip to content

Commit 3d9e6d4

Browse files
committed
⬆️ Update pre-commit and auto fix from hooks
1 parent bdc4a9b commit 3d9e6d4

File tree

9 files changed

+50
-74
lines changed

9 files changed

+50
-74
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ repos:
1515
- id: check-added-large-files
1616
args: ['--maxkb=1024']
1717
- repo: https://github.com/tox-dev/pyproject-fmt
18-
rev: v2.11.1
18+
rev: v2.14.2
1919
hooks:
2020
- id: pyproject-fmt
2121
- repo: https://github.com/abravalheri/validate-pyproject
22-
rev: v0.24.1
22+
rev: v0.25
2323
hooks:
2424
- id: validate-pyproject
2525
- repo: https://github.com/sphinx-contrib/sphinx-lint
@@ -35,7 +35,7 @@ repos:
3535
entry: isort --profile=black
3636
name: isort (python)
3737
- repo: https://github.com/psf/black-pre-commit-mirror
38-
rev: 25.12.0
38+
rev: 26.1.0
3939
hooks:
4040
- id: black
4141
- repo: https://github.com/adamchainz/blacken-docs

docs/save-data/sqlite/create-data.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ Create data
55

66
.. literalinclude:: create_data.py
77
:language: python
8-
:lines: 7-10
8+
:lines: 7-9
99
:lineno-start: 7
1010

1111
#. Save data to database:
1212

1313
.. literalinclude:: create_data.py
1414
:language: python
15-
:lines: 14
16-
:lineno-start: 14
15+
:lines: 12
16+
:lineno-start: 12
1717

1818
#. Insert multiple records using the more secure ``?`` method where the number
1919
of ``?`` should correspond to the number of columns:
2020

2121
.. literalinclude:: create_data.py
2222
:language: python
23-
:lines: 17-
24-
:lineno-start: 17
23+
:lines: 15-
24+
:lineno-start: 15

docs/save-data/sqlite/create_data.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
cursor = conn.cursor()
55

66
# insert a record into the database
7-
cursor.execute(
8-
"""INSERT INTO books
7+
cursor.execute("""INSERT INTO books
98
VALUES ('Python basics', 'en', 'Veit Schiele', 'BSD',
10-
'2021-10-28')"""
11-
)
9+
'2021-10-28')""")
1210

1311
# save data to database
1412
conn.commit()

docs/save-data/sqlite/create_db.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
cursor = conn.cursor()
77

88
# create books table
9-
cursor.execute(
10-
"""CREATE TABLE books
9+
cursor.execute("""CREATE TABLE books
1110
(title text, language text, author text, license text,
1211
release_date text)
13-
"""
14-
)
12+
""")

docs/save-data/sqlite/normalise.py

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,17 @@
33
conn = sqlite3.connect("library.db")
44
cursor = conn.cursor()
55

6-
cursor.execute(
7-
"""CREATE TABLE languages
6+
cursor.execute("""CREATE TABLE languages
87
(id INTEGER PRIMARY KEY AUTOINCREMENT,
9-
language_code VARCHAR(2))"""
10-
)
8+
language_code VARCHAR(2))""")
119

12-
cursor.execute(
13-
"""INSERT INTO languages (language_code)
14-
VALUES ('de')"""
15-
)
10+
cursor.execute("""INSERT INTO languages (language_code)
11+
VALUES ('de')""")
1612

17-
cursor.execute(
18-
"""INSERT INTO languages (language_code)
19-
VALUES ('en')"""
20-
)
13+
cursor.execute("""INSERT INTO languages (language_code)
14+
VALUES ('en')""")
2115

22-
cursor.execute(
23-
"""CREATE TABLE "temp" (
16+
cursor.execute("""CREATE TABLE "temp" (
2417
"id" INTEGER,
2518
"title" TEXT,
2619
"language_code" INTEGER REFERENCES languages(id),
@@ -29,25 +22,18 @@
2922
"license" TEXT,
3023
"release_date" DATE,
3124
PRIMARY KEY("id" AUTOINCREMENT)
32-
)"""
33-
)
25+
)""")
3426

35-
cursor.execute(
36-
"""INSERT INTO temp (title,language,author,license,release_date)
37-
SELECT title,language,author,license,release_date FROM books"""
38-
)
27+
cursor.execute("""INSERT INTO temp (title,language,author,license,release_date)
28+
SELECT title,language,author,license,release_date FROM books""")
3929

40-
cursor.execute(
41-
"""UPDATE temp
30+
cursor.execute("""UPDATE temp
4231
SET language_code = 1
43-
WHERE language = 'de'"""
44-
)
32+
WHERE language = 'de'""")
4533

46-
cursor.execute(
47-
"""UPDATE temp
34+
cursor.execute("""UPDATE temp
4835
SET language_code = 2
49-
WHERE language = 'en'"""
50-
)
36+
WHERE language = 'en'""")
5137

5238
# Only SQLite ≥ 3.35.0 allows DROP COLUMN;
5339
# Only Python versions ≥ 3.8 released after 27 April 2021 will receive these or

docs/save-data/sqlite/normalise.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,46 @@ published.
1616

1717
.. literalinclude:: normalise.py
1818
:language: python
19-
:lines: 6-9
19+
:lines: 6-8
2020
:lineno-start: 6
2121

2222
#. Then we create the values ``de`` and ``en`` in this table:
2323

2424
.. literalinclude:: normalise.py
2525
:language: python
26-
:lines: 12-18
27-
:lineno-start: 12
26+
:lines: 10-14
27+
:lineno-start: 10
2828

2929
#. Since SQLite does not support ``MODIFY COLUMN``, we now create a temporary
3030
table ``temp`` with all columns from ``books`` and a column ``language_code``
3131
that uses the column ``id`` from the ``languages`` table as a foreign key:
3232

3333
.. literalinclude:: normalise.py
3434
:language: python
35-
:lines: 22-32
36-
:lineno-start: 22
35+
:lines: 16-25
36+
:lineno-start: 16
3737

3838
#. Now we transfer the values from the ``books`` table to the ``temp`` table:
3939

4040
.. literalinclude:: normalise.py
4141
:language: python
42-
:lines: 35-37
43-
:lineno-start: 35
42+
:lines: 27-28
43+
:lineno-start: 27
4444

4545
#. Transfer the specification of the language in ``books`` as the ``id`` of the
4646
data records from the ``languages`` table to ``temp``.
4747

4848
.. literalinclude:: normalise.py
4949
:language: python
50-
:lines: 40-44
51-
:lineno-start: 40
50+
:lines: 30-36
51+
:lineno-start: 30
5252

5353
#. Now we can delete the ``languages`` column in the ``temp`` table:
5454

5555
.. literalinclude:: normalise.py
5656
:language: python
57-
:lines: 55
58-
:lineno-start: 55
57+
:lines: 41
58+
:lineno-start: 41
5959

6060
.. note::
6161
``DROP COLUMN`` can only be used from Python versions from 3.8 that were
@@ -69,12 +69,12 @@ published.
6969

7070
.. literalinclude:: normalise.py
7171
:language: python
72-
:lines: 57
73-
:lineno-start: 57
72+
:lines: 43
73+
:lineno-start: 43
7474

7575
#. And finally, the ``temp`` table can be renamed ``books``:
7676

7777
.. literalinclude:: normalise.py
7878
:language: python
79-
:lines: 59
80-
:lineno-start: 59
79+
:lines: 45
80+
:lineno-start: 45

docs/save-data/sqlite/query-normalised.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Query normalised data
55

66
.. literalinclude:: query_normalised.py
77
:language: python
8-
:lines: 7-13
8+
:lines: 7-11
99
:lineno-start: 7
1010

1111
.. code-block:: pycon
@@ -27,8 +27,8 @@ Query normalised data
2727

2828
.. literalinclude:: query_normalised.py
2929
:language: python
30-
:lines: 16-24
31-
:lineno-start: 16
30+
:lines: 14-22
31+
:lineno-start: 14
3232

3333
.. code-block:: pycon
3434

docs/save-data/sqlite/query_normalised.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66

77
def select_all_records_ordered_by_language_number(cursor):
88
print("All books ordered by language id and title:")
9-
for row in cursor.execute(
10-
"""SELECT language_code, author, title FROM books
11-
ORDER BY language_code,title"""
12-
):
9+
for row in cursor.execute("""SELECT language_code, author, title FROM books
10+
ORDER BY language_code,title"""):
1311
print(row)
1412

1513

docs/save-data/sqlite/test_sqlite.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,14 @@ def setUp(self):
1919
self.conn = sqlite3.connect(":memory:")
2020
cursor = self.conn.cursor()
2121

22-
cursor.execute(
23-
"""CREATE TABLE books
22+
cursor.execute("""CREATE TABLE books
2423
(title text, language text, author text, license text,
2524
release_date text)
26-
"""
27-
)
25+
""")
2826

29-
cursor.execute(
30-
"""INSERT INTO books
27+
cursor.execute("""INSERT INTO books
3128
VALUES ('Python basics', 'en', 'Veit Schiele', 'BSD',
32-
'2021-10-28')"""
33-
)
29+
'2021-10-28')""")
3430

3531
def test_func_like(self):
3632
self.conn = sqlite3.connect(":memory:")

0 commit comments

Comments
 (0)