diff --git a/.prospector.yaml b/.prospector.yaml index 8eb06f623..67a51acff 100644 --- a/.prospector.yaml +++ b/.prospector.yaml @@ -11,7 +11,7 @@ ignore-patterns: pylint: options: - extension-pkg-allow-list: cairo, SQLiteDict + extension-pkg-allow-list: cairo disable: - cyclic-import # see: https://github.com/PyCQA/pylint/issues/850 diff --git a/tilecloud/__init__.py b/tilecloud/__init__.py index 485b262f2..1194718bf 100644 --- a/tilecloud/__init__.py +++ b/tilecloud/__init__.py @@ -744,7 +744,7 @@ def load(name: str, allows_no_contenttype: bool = False) -> "TileStore": # prag from tilecloud.store.bsddb import BSDDBTileStore - return BSDDBTileStore(bsddb.hashopen(name)) + return BSDDBTileStore(bsddb.hashopen(name)) # pylint: disable=no-member if ext == ".mbtiles": import sqlite3 diff --git a/tilecloud/lib/sqlite3_.py b/tilecloud/lib/sqlite3_.py index f0f1dcc02..cd31d7319 100644 --- a/tilecloud/lib/sqlite3_.py +++ b/tilecloud/lib/sqlite3_.py @@ -4,6 +4,9 @@ from tilecloud import TileCoord +# For me this class can't works! +# flake8: noqa + def _query(connection: Connection, *args: Any) -> Cursor: cursor = connection.cursor() @@ -22,57 +25,57 @@ class SQLiteDict(Base): def __init__( self, - connection: Connection, commit: bool = True, + connection: Any = None, **kwargs: bytes, ) -> None: self.connection = connection self.commit = commit - _query(self.connection, self.CREATE_TABLE_SQL) # type: ignore + _query(self.connection, self.CREATE_TABLE_SQL) # pylint: disable=no-member # type: ignore[attr-defined] if self.commit: self.connection.commit() # Convert a Dict to a Mapping self.update({k: v for k, v in kwargs.items()}) # pylint: disable=unnecessary-comprehension - def __contains__(self, key: Union[str, TileCoord]) -> bool: # type: ignore - return _query(self.connection, self.CONTAINS_SQL, self._packkey(key)).fetchone()[0] # type: ignore + def __contains__(self, key: Union[str, TileCoord]) -> bool: + return _query(self.connection, self.CONTAINS_SQL, self._packkey(key)).fetchone()[0] # pylint: disable=no-member # type: ignore[attr-defined] def __delitem__(self, key: Union[str, TileCoord]) -> None: - _query(self.connection, self.DELITEM_SQL, self._packkey(key)) # type: ignore + _query(self.connection, self.DELITEM_SQL, self._packkey(key)) # pylint: disable=no-member # type: ignore[attr-defined] if self.commit: self.connection.commit() def __getitem__(self, key: Union[str, TileCoord]) -> Optional[bytes]: - row = _query(self.connection, self.GETITEM_SQL, self._packkey(key)).fetchone() # type: ignore + row = _query(self.connection, self.GETITEM_SQL, self._packkey(key)).fetchone() # pylint: disable=no-member # type: ignore[attr-defined] if row is None: return None return self._unpackvalue(row) def __iter__(self) -> Iterator[str]: - return map(self._unpackkey, _query(self.connection, self.ITER_SQL)) # type: ignore + return map(self._unpackkey, _query(self.connection, self.ITER_SQL)) # pylint: disable=no-member # type: ignore[attr-defined] def __len__(self) -> int: - return _query(self.connection, self.LEN_SQL).fetchone()[0] # type: ignore + return _query(self.connection, self.LEN_SQL).fetchone()[0] # pylint: disable=no-member # type: ignore[attr-defined] def __setitem__(self, key: Union[str, TileCoord], value: Any) -> None: - _query(self.connection, self.SETITEM_SQL, self._packitem(key, value)) # type: ignore + _query(self.connection, self.SETITEM_SQL, self._packitem(key, value)) # pylint: disable=no-member # type: ignore[attr-defined] if self.commit: self.connection.commit() def iteritems(self) -> Iterator[Cursor]: - return map(self._unpackitem, _query(self.connection, self.ITERITEMS_SQL)) # type: ignore + return map(self._unpackitem, _query(self.connection, self.ITERITEMS_SQL)) # pylint: disable=no-member # type: ignore[attr-defined] def itervalues(self) -> Iterator[tuple[bytes]]: - return map(self._unpackvalue, _query(self.connection, self.ITERVALUES_SQL)) # type: ignore + return map(self._unpackvalue, _query(self.connection, self.ITERVALUES_SQL)) # pylint: disable=no-member # type: ignore[attr-defined] def keys(self) -> KeysView[str]: - return set(iter(self)) # type: ignore + return set(iter(self)) def _packitem(self, key: TileCoord, value: Optional[bytes]) -> tuple[int, int, int, Optional[memoryview]]: - return (key, value) # type: ignore + return (key, value) def _packkey(self, key: TileCoord) -> tuple[int, int, int]: - return (key,) # type: ignore + return (key,) @staticmethod def _packvalue(value: Any) -> tuple[Any]: # pragma: no cover diff --git a/tilecloud/store/mbtiles.py b/tilecloud/store/mbtiles.py index 2018523b4..25ffeca12 100644 --- a/tilecloud/store/mbtiles.py +++ b/tilecloud/store/mbtiles.py @@ -79,7 +79,7 @@ def __init__( self, connection: Connection, commit: bool = True, tilecoord_in_topleft: bool = False, **kwargs: Any ) -> None: self.connection = connection - self.metadata = Metadata(self.connection, commit) + self.metadata = Metadata(self.connection, commit) # type: ignore[arg-type] # pylint: disable=no-member self.tiles = Tiles(tilecoord_in_topleft, self.connection, commit) if "content_type" not in kwargs and "format" in self.metadata: kwargs["content_type"] = mimetypes.types_map.get("." + self.metadata["format"]) # type: ignore diff --git a/tilecloud/store/s3.py b/tilecloud/store/s3.py index 675b9cc36..bd5e3d37b 100644 --- a/tilecloud/store/s3.py +++ b/tilecloud/store/s3.py @@ -28,7 +28,7 @@ def __init__( **kwargs: Any, ) -> None: self._s3_host = s3_host - self._client: Optional[botocore.client.S3] = None + self._client: Optional[botocore.client.S3] = None # pylint: disable=no-member self.bucket = bucket self.tilelayout = tilelayout self.dry_run = dry_run diff --git a/tilecloud/store/tilejson.py b/tilecloud/store/tilejson.py index ec93d2ab3..e7fc91423 100644 --- a/tilecloud/store/tilejson.py +++ b/tilecloud/store/tilejson.py @@ -34,7 +34,7 @@ def __init__(self, tile_json: str, urls_key: str = "tiles", **kwargs: Any): zmin, zmax = tile.get("minzoom", 0), tile.get("maxzoom", 22) if "bounds" in tile: lonmin, latmin, lonmax, latmax = tile["bounds"] - bounding_pyramid = BoundingPyramid.from_wgs84( # type: ignore + bounding_pyramid = BoundingPyramid.from_wgs84( # type: ignore[attr-defined] # pylint: disable=no-member zmin, zmax, lonmin, lonmax, latmin, latmax ) else: