-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yet more cleanup (Sourcery refactored) #33
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -905,7 +905,7 @@ def __delattr__(self, key): | |
raise AttributeError(f"Unknown field: {key}") from exc | ||
|
||
def __repr__(self): | ||
return "<AttrDict " + dict.__repr__(self) + ">" | ||
return f"<AttrDict {dict.__repr__(self)}>" | ||
|
||
|
||
def _ping(cursor): | ||
|
@@ -921,17 +921,15 @@ def _safe_close(obj): | |
Call the close method on an object safely. | ||
""" | ||
# pylint: disable-msg=W0702 | ||
try: | ||
with contextlib.suppress(Exception): | ||
obj.close() | ||
except Exception: # pragma: no cover | ||
pass | ||
Comment on lines
-924
to
-927
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
This removes the following comments ( why? ):
|
||
|
||
|
||
def to_dict(key, resultset): | ||
""" | ||
Convert a resultset into a dictionary keyed off of one of its columns. | ||
""" | ||
return dict((row[key], row) for row in resultset) | ||
return {row[key]: row for row in resultset} | ||
Comment on lines
-934
to
+932
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def make_placeholders(seq, start=1): | ||
|
@@ -955,8 +953,7 @@ def make_placeholders(seq, start=1): | |
) | ||
if placeholders is None: | ||
raise NotSupportedError( | ||
"Param style '%s' does not support sequence type '%s'" | ||
% (param_style, seq.__class__.__name__) | ||
f"Param style '{param_style}' does not support sequence type '{seq.__class__.__name__}'" | ||
Comment on lines
-958
to
+956
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
) | ||
return ", ".join(placeholders) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,11 +60,9 @@ def test_context(self): | |
self.assertTrue(dbkit.Context.current(with_exception=False) is ctx) | ||
self.assertTrue(ctx.mdr is not None) | ||
ctx.close() | ||
try: | ||
with contextlib.suppress(Exception): | ||
dbkit.context() | ||
self.fail("Should not have been able to access context.") | ||
except Exception: | ||
pass | ||
Comment on lines
-63
to
-67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
self.assertTrue(ctx.mdr is None) | ||
self.assertEqual(len(ctx.stack), 0) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
AttrDict.__repr__
refactored with the following changes:use-fstring-for-concatenation
)