Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 18163d7

Browse filesBrowse files
jnozscmethane
authored andcommitted
code cleanup and reformat (PyMySQL#423)
1 parent 0f1ff4c commit 18163d7
Copy full SHA for 18163d7
Expand file treeCollapse file tree

25 files changed

+1421
-1079
lines changed

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,20 @@ jobs:
5959
script:
6060
- cd django-${DJANGO_VERSION}/tests/
6161
- ./runtests.py --parallel=1 --settings=test_mysql
62-
62+
- name: flake8
63+
python: "3.8"
64+
install:
65+
- pip install -U pip
66+
- pip install flake8
67+
script:
68+
- flake8 --ignore=E203,E501,W503 --max-line-length=88 .
69+
- name: black
70+
python: "3.8"
71+
install:
72+
- pip install -U pip
73+
- pip install black
74+
script:
75+
- black --check --exclude=doc/ .
6376
#- &django_3_0
6477
# <<: *django_2_2
6578
# name: "Django 3.0 test (Python 3.8)"

‎MySQLdb/__init__.py

Copy file name to clipboardExpand all lines: MySQLdb/__init__.py
+123-37Lines changed: 123 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,57 @@
1313
MySQLdb.converters module.
1414
"""
1515

16-
from MySQLdb.release import __version__, version_info, __author__
17-
18-
from . import _mysql
19-
20-
if version_info != _mysql.version_info:
21-
raise ImportError("this is MySQLdb version %s, but _mysql is version %r\n_mysql: %r" %
22-
(version_info, _mysql.version_info, _mysql.__file__))
23-
24-
threadsafety = 1
25-
apilevel = "2.0"
26-
paramstyle = "format"
27-
28-
from ._mysql import *
16+
try:
17+
from MySQLdb.release import version_info
18+
from . import _mysql
19+
20+
assert version_info == _mysql.version_info
21+
except Exception:
22+
raise ImportError(
23+
"this is MySQLdb version {}, but _mysql is version {!r}\n_mysql: {!r}".format(
24+
version_info, _mysql.version_info, _mysql.__file__
25+
)
26+
)
27+
28+
29+
from ._mysql import (
30+
NotSupportedError,
31+
OperationalError,
32+
get_client_info,
33+
ProgrammingError,
34+
Error,
35+
InterfaceError,
36+
debug,
37+
IntegrityError,
38+
string_literal,
39+
MySQLError,
40+
DataError,
41+
escape,
42+
escape_string,
43+
DatabaseError,
44+
InternalError,
45+
Warning,
46+
)
2947
from MySQLdb.constants import FIELD_TYPE
30-
from MySQLdb.times import Date, Time, Timestamp, \
31-
DateFromTicks, TimeFromTicks, TimestampFromTicks
48+
from MySQLdb.times import (
49+
Date,
50+
Time,
51+
Timestamp,
52+
DateFromTicks,
53+
TimeFromTicks,
54+
TimestampFromTicks,
55+
)
3256

3357
try:
3458
frozenset
3559
except NameError:
3660
from sets import ImmutableSet as frozenset
3761

62+
threadsafety = 1
63+
apilevel = "2.0"
64+
paramstyle = "format"
65+
66+
3867
class DBAPISet(frozenset):
3968
"""A special type of set for which A == x is true if A is a
4069
DBAPISet and x is a member of that set."""
@@ -45,49 +74,106 @@ def __eq__(self, other):
4574
return other in self
4675

4776

48-
STRING = DBAPISet([FIELD_TYPE.ENUM, FIELD_TYPE.STRING,
49-
FIELD_TYPE.VAR_STRING])
50-
BINARY = DBAPISet([FIELD_TYPE.BLOB, FIELD_TYPE.LONG_BLOB,
51-
FIELD_TYPE.MEDIUM_BLOB, FIELD_TYPE.TINY_BLOB])
52-
NUMBER = DBAPISet([FIELD_TYPE.DECIMAL, FIELD_TYPE.DOUBLE, FIELD_TYPE.FLOAT,
53-
FIELD_TYPE.INT24, FIELD_TYPE.LONG, FIELD_TYPE.LONGLONG,
54-
FIELD_TYPE.TINY, FIELD_TYPE.YEAR, FIELD_TYPE.NEWDECIMAL])
55-
DATE = DBAPISet([FIELD_TYPE.DATE])
56-
TIME = DBAPISet([FIELD_TYPE.TIME])
77+
STRING = DBAPISet([FIELD_TYPE.ENUM, FIELD_TYPE.STRING, FIELD_TYPE.VAR_STRING])
78+
BINARY = DBAPISet(
79+
[
80+
FIELD_TYPE.BLOB,
81+
FIELD_TYPE.LONG_BLOB,
82+
FIELD_TYPE.MEDIUM_BLOB,
83+
FIELD_TYPE.TINY_BLOB,
84+
]
85+
)
86+
NUMBER = DBAPISet(
87+
[
88+
FIELD_TYPE.DECIMAL,
89+
FIELD_TYPE.DOUBLE,
90+
FIELD_TYPE.FLOAT,
91+
FIELD_TYPE.INT24,
92+
FIELD_TYPE.LONG,
93+
FIELD_TYPE.LONGLONG,
94+
FIELD_TYPE.TINY,
95+
FIELD_TYPE.YEAR,
96+
FIELD_TYPE.NEWDECIMAL,
97+
]
98+
)
99+
DATE = DBAPISet([FIELD_TYPE.DATE])
100+
TIME = DBAPISet([FIELD_TYPE.TIME])
57101
TIMESTAMP = DBAPISet([FIELD_TYPE.TIMESTAMP, FIELD_TYPE.DATETIME])
58-
DATETIME = TIMESTAMP
59-
ROWID = DBAPISet()
102+
DATETIME = TIMESTAMP
103+
ROWID = DBAPISet()
104+
60105

61106
def test_DBAPISet_set_equality():
62107
assert STRING == STRING
63108

109+
64110
def test_DBAPISet_set_inequality():
65111
assert STRING != NUMBER
66112

113+
67114
def test_DBAPISet_set_equality_membership():
68115
assert FIELD_TYPE.VAR_STRING == STRING
69116

117+
70118
def test_DBAPISet_set_inequality_membership():
71119
assert FIELD_TYPE.DATE != STRING
72120

121+
73122
def Binary(x):
74123
return bytes(x)
75124

125+
76126
def Connect(*args, **kwargs):
77127
"""Factory function for connections.Connection."""
78128
from MySQLdb.connections import Connection
129+
79130
return Connection(*args, **kwargs)
80131

81-
connect = Connection = Connect
82132

83-
__all__ = [ 'BINARY', 'Binary', 'Connect', 'Connection', 'DATE',
84-
'Date', 'Time', 'Timestamp', 'DateFromTicks', 'TimeFromTicks',
85-
'TimestampFromTicks', 'DataError', 'DatabaseError', 'Error',
86-
'FIELD_TYPE', 'IntegrityError', 'InterfaceError', 'InternalError',
87-
'MySQLError', 'NUMBER', 'NotSupportedError', 'DBAPISet',
88-
'OperationalError', 'ProgrammingError', 'ROWID', 'STRING', 'TIME',
89-
'TIMESTAMP', 'Warning', 'apilevel', 'connect', 'connections',
90-
'constants', 'converters', 'cursors', 'debug', 'escape',
91-
'escape_string', 'get_client_info',
92-
'paramstyle', 'string_literal', 'threadsafety', 'version_info']
133+
connect = Connection = Connect
93134

135+
__all__ = [
136+
"BINARY",
137+
"Binary",
138+
"Connect",
139+
"Connection",
140+
"DATE",
141+
"Date",
142+
"Time",
143+
"Timestamp",
144+
"DateFromTicks",
145+
"TimeFromTicks",
146+
"TimestampFromTicks",
147+
"DataError",
148+
"DatabaseError",
149+
"Error",
150+
"FIELD_TYPE",
151+
"IntegrityError",
152+
"InterfaceError",
153+
"InternalError",
154+
"MySQLError",
155+
"NUMBER",
156+
"NotSupportedError",
157+
"DBAPISet",
158+
"OperationalError",
159+
"ProgrammingError",
160+
"ROWID",
161+
"STRING",
162+
"TIME",
163+
"TIMESTAMP",
164+
"Warning",
165+
"apilevel",
166+
"connect",
167+
"connections",
168+
"constants",
169+
"converters",
170+
"cursors",
171+
"debug",
172+
"escape",
173+
"escape_string",
174+
"get_client_info",
175+
"paramstyle",
176+
"string_literal",
177+
"threadsafety",
178+
"version_info",
179+
]

‎MySQLdb/_exceptions.py

Copy file name to clipboardExpand all lines: MySQLdb/_exceptions.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
https://www.python.org/dev/peps/pep-0249/
66
"""
77

8+
89
class MySQLError(Exception):
910
"""Exception related to operation with MySQL."""
1011

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.