Skip to content

Commit a3b74f8

Browse files
committed
Add pylint
1 parent f98f1a1 commit a3b74f8

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ dist: xenial
66
install:
77
- pip install fs sqlalchemy pytest python-coveralls coverage
88
script:
9+
- pylint src/sqliteupload
910
- coverage run --source . -m pytest
1011
- coverage report --omit */Lib/*,tests/*
1112
- coverage html --omit */Lib/*,tests/*

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# sqlalchemy-sqliteupload
22

3-
[![Build Status](https://travis-ci.org/rkhwaja/sqlalchemy-sqliteupload.svg?branch=master)](https://travis-ci.org/rkhwaja/sqlalchemy-sqliteupload)
4-
5-
[![Coverage Status](https://coveralls.io/repos/github/rkhwaja/sqlalchemy-sqliteupload/badge.svg?branch=master)](https://coveralls.io/github/rkhwaja/sqlalchemy-sqliteupload?branch=master)
3+
[![Build Status](https://travis-ci.org/rkhwaja/sqlalchemy-sqliteupload.svg?branch=master)](https://travis-ci.org/rkhwaja/sqlalchemy-sqliteupload) [![Coverage Status](https://coveralls.io/repos/github/rkhwaja/sqlalchemy-sqliteupload/badge.svg?branch=master)](https://coveralls.io/github/rkhwaja/sqlalchemy-sqliteupload?branch=master)
64

75
Based on [sqlalchemy-s3sqlite](//github.com/cariaso/sqlalchemy-s3sqlite)
86

pylintrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[FORMAT]
2+
indent-string=\t
3+
max-line-length=200
4+
5+
[MESSAGES CONTROL]
6+
# no-member causes false positives with objects constructed via google's discovery protocol
7+
disable=bad-continuation, fixme, invalid-name, len-as-condition, missing-docstring, no-member

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fs = "^2.4"
1111

1212
[tool.poetry.dev-dependencies]
1313
pytest = "^3.0"
14+
pylint = "^2.3"
1415

1516
[build-system]
1617
requires = ["poetry>=0.12"]

src/sqliteupload/dialect.py

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from contextlib import suppress
22
from hashlib import md5
3-
from io import BytesIO
4-
from logging import debug, info
3+
from logging import debug
54
from os import close, remove
65
from tempfile import mkstemp
76

@@ -15,16 +14,18 @@ def _hash_of_bytes(bytes_):
1514
hash_.update(bytes_)
1615
return hash_.hexdigest()
1716

18-
class SQLiteUploadDialect(SQLiteDialect_pysqlite):
17+
class SQLiteUploadDialect(SQLiteDialect_pysqlite): # pylint: disable=abstract-method
1918

2019
def __init__(self, *args, **kw):
2120
super().__init__(*args, **kw)
2221
handle, self._localPath = mkstemp()
2322
close(handle)
2423
self._localHash = None
2524
debug(f"localPath: {self._localPath}")
25+
self._remoteFilename = None
26+
self._fs = None
2627

27-
def close(self, *args, **kwargs):
28+
def close(self, *args, **kwargs): # pylint: disable=unused-argument
2829
with open(self._localPath, "rb") as f:
2930
bytes_ = f.read()
3031

@@ -40,8 +41,8 @@ def connect(self, *args, **kw):
4041
self._load_remote_db(uploadUrl)
4142
return super().connect(self._localPath, **kw)
4243

43-
def do_close(self, *args, **kw):
44-
out = super().do_close(*args, **kw)
44+
def do_close(self, dbapi_connection):
45+
out = super().do_close(dbapi_connection)
4546
self.close()
4647
return out
4748

@@ -50,7 +51,7 @@ def _load_remote_db(self, remotePath):
5051
fsurl = remotePath[:lastSeparator]
5152
self._remoteFilename = remotePath[lastSeparator + 1:]
5253
self._fs = open_fs(fsurl)
53-
54+
5455
try:
5556
remoteBytes = self._fs.readbytes(self._remoteFilename)
5657
with open(self._localPath, "wb") as localFile: # truncate any existing files
@@ -63,7 +64,8 @@ def _load_remote_db(self, remotePath):
6364
remove(self._localPath)
6465
self._localHash = None
6566

66-
urlScheme = "sqliteupload"
67-
6867
def RegisterDialect():
69-
registry.register(urlScheme, "sqliteupload.dialect", SQLiteUploadDialect.__name__)
68+
registry.register(
69+
name="sqliteupload",
70+
modulepath="sqliteupload.dialect",
71+
objname=SQLiteUploadDialect.__name__)

0 commit comments

Comments
 (0)