Changeset - cbd50af302e6
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-04-06 19:21:56
brettcsmith@brettcsmith.org
rtutil: Explicit fspath cast to avoid a Py3.6 typecheck issue.

On Py3.6, either sqlite3.connect() doesn't take a path-like object,
or the type stubs don't know that.
1 file changed with 2 insertions and 1 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/rtutil.py
Show inline comments
...
 
@@ -13,12 +13,13 @@
 
#
 
# You should have received a copy of the GNU Affero General Public License
 
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 

	
 
import functools
 
import mimetypes
 
import os
 
import re
 
import sqlite3
 
import urllib.parse as urlparse
 

	
 
import rt
 

	
...
 
@@ -70,13 +71,13 @@ class RTLinkCache(_LinkCache):
 
 PRIMARY KEY (ticket_id, attachment_id)
 
)"""
 

	
 
    @classmethod
 
    def setup(cls, cache_path: Path) -> Optional[sqlite3.Connection]:
 
        try:
 
            db = sqlite3.connect(cache_path, isolation_level=None)
 
            db = sqlite3.connect(os.fspath(cache_path), isolation_level=None)
 
            cursor = db.cursor()
 
            cursor.execute(cls.CREATE_TABLE_SQL)
 
            cursor.execute('SELECT url FROM RTLinkCache LIMIT 1')
 
            have_data = cursor.fetchone() is not None
 
        except sqlite3.OperationalError:
 
            # If we couldn't get this far, sqlite provides no benefit.
0 comments (0 inline, 0 general)