Skip to content

Commit ca41d10

Browse files
bjesterclaude
andcommitted
Reformat files previously excluded from ruff
Formatting and import sorting only, produced by ruff 0.15.16 with the project config. No behavior change: each file's AST is unchanged apart from import order and dropped u"" string prefixes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 71beb39 commit ca41d10

5 files changed

Lines changed: 102 additions & 160 deletions

File tree

‎docs/conf.py‎

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def process_docstring(app, what, name, obj, options, lines):
6464
for field in fields:
6565
# Skip ManyToOneRel and ManyToManyRel fields
6666
# which have no 'verbose_name' or 'help_text'
67-
if not hasattr(field, 'verbose_name'):
67+
if not hasattr(field, "verbose_name"):
6868
continue
6969

7070
# Decode and strip any html out of the field's help text
@@ -77,24 +77,20 @@ def process_docstring(app, what, name, obj, options, lines):
7777
if help_text:
7878
# Add the model field to the end of the docstring as a param
7979
# using the help text as the description
80-
lines.append(u':param %s: %s' % (field.attname, help_text))
80+
lines.append(":param %s: %s" % (field.attname, help_text))
8181
else:
8282
# Add the model field to the end of the docstring as a param
8383
# using the verbose name as the description
84-
lines.append(u':param %s: %s' % (field.attname, verbose_name))
84+
lines.append(":param %s: %s" % (field.attname, verbose_name))
8585

8686
# Add the field's type to the docstring
8787
if isinstance(field, models.ForeignKey):
8888
to = field.remote_field.model
8989
lines.append(
90-
u':type %s: %s to :class:`~%s`'
91-
% (field.attname, type(field).__name__, to)
90+
":type %s: %s to :class:`~%s`" % (field.attname, type(field).__name__, to)
9291
)
9392
else:
94-
lines.append(
95-
u':type %s: %s'
96-
% (field.attname, type(field).__name__)
97-
)
93+
lines.append(":type %s: %s" % (field.attname, type(field).__name__))
9894

9995
return lines
10096

@@ -106,18 +102,18 @@ def process_docstring(app, what, name, obj, options, lines):
106102
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"]
107103

108104
# Add any paths that contain templates here, relative to this directory.
109-
templates_path = ['_templates']
105+
templates_path = ["_templates"]
110106

111107
# The suffix(es) of source filenames.
112108
# You can specify multiple suffix as a list of string:
113109
source_suffix = [".rst"]
114110

115111
# The master toctree document.
116-
master_doc = 'index'
112+
master_doc = "index"
117113

118114
# General information about the project.
119-
project = u"Morango developer documentation"
120-
copyright = u"2020 Learning Equality"
115+
project = "Morango developer documentation"
116+
copyright = "2020 Learning Equality"
121117

122118
# The version info for the project you're documenting, acts as replacement
123119
# for |version| and |release|, also used in various other places throughout
@@ -140,7 +136,7 @@ def process_docstring(app, what, name, obj, options, lines):
140136

141137
# List of patterns, relative to source directory, that match files and
142138
# directories to ignore when looking for source files.
143-
exclude_patterns = ['_build']
139+
exclude_patterns = ["_build"]
144140

145141
# The reST default role (used for this markup: `text`) to use for all
146142
# documents.
@@ -158,7 +154,7 @@ def process_docstring(app, what, name, obj, options, lines):
158154
# show_authors = False
159155

160156
# The name of the Pygments (syntax highlighting) style to use.
161-
pygments_style = 'sphinx'
157+
pygments_style = "sphinx"
162158

163159
# A list of ignored prefixes for module index sorting.
164160
# modindex_common_prefix = []
@@ -257,18 +253,16 @@ def setup(app):
257253
# html_file_suffix = None
258254

259255
# Output file base name for HTML help builder.
260-
htmlhelp_basename = 'morangodoc'
256+
htmlhelp_basename = "morangodoc"
261257

262258

263259
# -- Options for LaTeX output ------------------------------------------
264260

265261
latex_elements = {
266262
# The paper size ('letterpaper' or 'a4paper').
267263
# 'papersize': 'letterpaper',
268-
269264
# The font size ('10pt', '11pt' or '12pt').
270265
# 'pointsize': '10pt',
271-
272266
# Additional stuff for the LaTeX preamble.
273267
# 'preamble': '',
274268
}
@@ -277,9 +271,7 @@ def setup(app):
277271
# (source start file, target name, title, author, documentclass
278272
# [howto/manual]).
279273
latex_documents = [
280-
('index', 'morango.tex',
281-
u'morango Documentation',
282-
u'Learning Equality', 'manual'),
274+
("index", "morango.tex", "morango Documentation", "Learning Equality", "manual"),
283275
]
284276

285277
# The name of an image file (relative to this directory) to place at
@@ -307,11 +299,7 @@ def setup(app):
307299

308300
# One entry per manual page. List of tuples
309301
# (source start file, name, description, authors, manual section).
310-
man_pages = [
311-
('index', 'morango',
312-
u'morango Documentation',
313-
[u'Learning Equality'], 1)
314-
]
302+
man_pages = [("index", "morango", "morango Documentation", ["Learning Equality"], 1)]
315303

316304
# If true, show URL addresses after external links.
317305
# man_show_urls = False
@@ -346,4 +334,4 @@ def setup(app):
346334
# If true, do not generate a @detailmenu in the "Top" node's menu.
347335
# texinfo_no_detailmenu = False
348336

349-
suppress_warnings = ['image.nonlocal_uri']
337+
suppress_warnings = ["image.nonlocal_uri"]

‎morango/sync/backends/postgres.py‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
import logging
33
from contextlib import contextmanager
44

5-
from .base import BaseSQLWrapper
6-
from .utils import get_pk_field
75
from morango.errors import MorangoDatabaseError
86
from morango.models.core import Buffer
97
from morango.models.core import RecordMaxCounter
108
from morango.models.core import RecordMaxCounterBuffer
119
from morango.models.core import Store
1210
from morango.utils import SETTINGS
1311

12+
from .base import BaseSQLWrapper
13+
from .utils import get_pk_field
1414

1515
# advisory lock integers for locking partitions
1616
LOCK_ALL_PARTITIONS = 1
@@ -23,9 +23,7 @@
2323

2424
class SQLWrapper(BaseSQLWrapper):
2525
backend = "postgresql"
26-
create_temporary_table_template = (
27-
"CREATE TEMP TABLE {name} ({fields}) ON COMMIT DROP"
28-
)
26+
create_temporary_table_template = "CREATE TEMP TABLE {name} ({fields}) ON COMMIT DROP"
2927

3028
def _is_transaction_isolation_error(self, error):
3129
"""
@@ -36,7 +34,7 @@ def _is_transaction_isolation_error(self, error):
3634
from psycopg2.extensions import TransactionRollbackError
3735

3836
# Django can wrap errors, adding it to the `__cause__` attribute
39-
for e in (error, getattr(error, '__cause__', None)):
37+
for e in (error, getattr(error, "__cause__", None)):
4038
if isinstance(e, TransactionRollbackError):
4139
return True
4240
return False
@@ -55,11 +53,15 @@ def _set_transaction_repeatable_read(self):
5553
# before any reading/writing operations have taken place, which includes creating
5654
# savepoints
5755
if self.connection.in_atomic_block:
58-
raise MorangoDatabaseError("Unable to set transaction isolation during a transaction")
56+
raise MorangoDatabaseError(
57+
"Unable to set transaction isolation during a transaction"
58+
)
5959

6060
for savepoint_id in self.connection.savepoint_ids:
6161
if savepoint_id is not None:
62-
raise MorangoDatabaseError("Unable to set transaction isolation when savepoints have been created")
62+
raise MorangoDatabaseError(
63+
"Unable to set transaction isolation when savepoints have been created"
64+
)
6365

6466
# ensure the postgres database wrapper loads the isolation level, which requires it to
6567
# connection to the database.
@@ -70,7 +72,9 @@ def _set_transaction_repeatable_read(self):
7072

7173
try:
7274
self.connection.isolation_level = ISOLATION_LEVEL_REPEATABLE_READ
73-
self.connection.connection.set_session(isolation_level=ISOLATION_LEVEL_REPEATABLE_READ, autocommit=False)
75+
self.connection.connection.set_session(
76+
isolation_level=ISOLATION_LEVEL_REPEATABLE_READ, autocommit=False
77+
)
7478
yield
7579
finally:
7680
self.connection.isolation_level = existing_isolation_level
@@ -99,9 +103,7 @@ def _prepare_with_values(self, name, fields, db_values):
99103
def _prepare_casted_fields(self, fields):
100104
return ", ".join(
101105
map(
102-
lambda f: "{f}::{type}".format(
103-
f=f.column, type=f.rel_db_type(self.connection)
104-
),
106+
lambda f: "{f}::{type}".format(f=f.column, type=f.rel_db_type(self.connection)),
105107
fields,
106108
)
107109
)
@@ -262,9 +264,7 @@ def _dequeuing_merge_conflict_buffer(self, cursor, current_id, transfersession_i
262264

263265
cursor.execute(merge_conflict_store)
264266

265-
def _dequeuing_update_rmcs_last_saved_by(
266-
self, cursor, current_id, transfersession_id
267-
):
267+
def _dequeuing_update_rmcs_last_saved_by(self, cursor, current_id, transfersession_id):
268268
# update or create rmc for merge conflicts with local instance id
269269
merge_conflict_store = """
270270
WITH new_values as
@@ -469,7 +469,7 @@ def _execute_lock(self, key1, key2=None, unlock=False, session=False, shared=Fal
469469
xact_="" if session else "xact_",
470470
lock="unlock" if unlock else "lock",
471471
_shared="_shared" if shared else "",
472-
keys=", ".join(["%s"] * len(keys))
472+
keys=", ".join(["%s"] * len(keys)),
473473
)
474474

475475
with self.connection.cursor() as c:

‎morango/sync/backends/sqlite.py‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
from .base import BaseSQLWrapper
2-
from .utils import calculate_max_sqlite_variables
3-
from .utils import get_pk_field
41
from morango.models.core import Buffer
52
from morango.models.core import RecordMaxCounter
63
from morango.models.core import RecordMaxCounterBuffer
74
from morango.models.core import Store
85

6+
from .base import BaseSQLWrapper
7+
from .utils import calculate_max_sqlite_variables
8+
from .utils import get_pk_field
9+
910

1011
class SQLWrapper(BaseSQLWrapper):
1112
backend = "sqlite"
@@ -51,9 +52,7 @@ def _bulk_insert(self, cursor, table_name, fields, db_values):
5152
for x in range(0, len(db_values), num_of_values_able_to_insert)
5253
]
5354
for value_chunk in value_chunks:
54-
super(SQLWrapper, self)._bulk_insert(
55-
cursor, table_name, fields, value_chunk
56-
)
55+
super(SQLWrapper, self)._bulk_insert(cursor, table_name, fields, value_chunk)
5756

5857
def _bulk_update(self, cursor, table_name, fields, db_values):
5958
"""
@@ -64,9 +63,7 @@ def _bulk_update(self, cursor, table_name, fields, db_values):
6463
# calculate and create equal sized chunks of data to update incrementally
6564
# for every field we're updating, we'll require 3 parameters
6665
num_update_fields = len(fields) - 1
67-
num_of_rows_able_to_update = (
68-
calculate_max_sqlite_variables() // num_update_fields // 3
69-
)
66+
num_of_rows_able_to_update = calculate_max_sqlite_variables() // num_update_fields // 3
7067
num_of_values_able_to_update = num_of_rows_able_to_update * len(fields)
7168
value_chunks = [
7269
db_values[x : x + num_of_values_able_to_update]
@@ -100,9 +97,7 @@ def _bulk_update(self, cursor, table_name, fields, db_values):
10097
table_name=table_name,
10198
set_sql=set_sql[:-1],
10299
pk_field=pk.column,
103-
placeholder_str="({})".format(
104-
",".join("%s" for _ in range(len(pk_params)))
105-
),
100+
placeholder_str="({})".format(",".join("%s" for _ in range(len(pk_params)))),
106101
)
107102
# use DB-APIs parameter substitution (2nd parameter expects a sequence)
108103
cursor.execute(update, params)
@@ -202,9 +197,7 @@ def _dequeuing_merge_conflict_buffer(self, cursor, current_id, transfersession_i
202197
)
203198
cursor.execute(merge_conflict_store)
204199

205-
def _dequeuing_update_rmcs_last_saved_by(
206-
self, cursor, current_id, transfersession_id
207-
):
200+
def _dequeuing_update_rmcs_last_saved_by(self, cursor, current_id, transfersession_id):
208201
# update or create rmc for merge conflicts with local instance id
209202
merge_conflict_store = """REPLACE INTO {rmc} (instance_id, counter, store_model_id)
210203
SELECT '{current_instance_id}', {current_instance_counter}, store.id

0 commit comments

Comments
 (0)