mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-28 18:56:44 +08:00
Add __slots__ to third-party packages using stubdefaulter (#14619)
This commit is contained in:
@@ -31,6 +31,7 @@ class JOIN_STYLE:
|
||||
bevel: Literal[BufferJoinStyle.bevel]
|
||||
|
||||
class BaseGeometry(Geometry):
|
||||
__slots__: list[str] = []
|
||||
@deprecated(
|
||||
"Directly calling 'BaseGeometry()' is deprecated. To create an empty geometry, "
|
||||
"use one of the subclasses instead, for example 'GeometryCollection()'."
|
||||
@@ -264,6 +265,7 @@ class BaseGeometry(Geometry):
|
||||
_GeoT_co = TypeVar("_GeoT_co", bound=Geometry, default=BaseGeometry, covariant=True)
|
||||
|
||||
class BaseMultipartGeometry(BaseGeometry, Generic[_GeoT_co]):
|
||||
__slots__: list[str] = []
|
||||
@property
|
||||
def coords(self) -> NoReturn: ...
|
||||
@property
|
||||
|
||||
@@ -7,6 +7,7 @@ from .base import BaseMultipartGeometry, GeometrySequence, _GeoT_co
|
||||
|
||||
class GeometryCollection(BaseMultipartGeometry[_GeoT_co]):
|
||||
# Overloads of __new__ are used because mypy is unable to narrow the typevar otherwise
|
||||
__slots__: list[str] = []
|
||||
@overload
|
||||
def __new__(
|
||||
self, geoms: BaseMultipartGeometry[_GeoT_co] | GeometrySequence[BaseMultipartGeometry[_GeoT_co]] | Collection[_GeoT_co]
|
||||
|
||||
@@ -15,6 +15,7 @@ __all__ = ["LineString"]
|
||||
_ConvertibleToLineString: TypeAlias = LineString | ArrayLikeSeq[float] | Iterable[Point | Iterable[SupportsFloat]]
|
||||
|
||||
class LineString(BaseGeometry):
|
||||
__slots__: list[str] = []
|
||||
def __new__(self, coordinates: _ConvertibleToLineString | None = None) -> Self: ...
|
||||
def svg(self, scale_factor: float = 1.0, stroke_color: str | None = None, opacity: float | None = None) -> str: ... # type: ignore[override]
|
||||
def offset_curve(
|
||||
|
||||
@@ -8,6 +8,7 @@ from .multipoint import MultiPoint
|
||||
__all__ = ["MultiLineString"]
|
||||
|
||||
class MultiLineString(BaseMultipartGeometry[LineString]):
|
||||
__slots__: list[str] = []
|
||||
def __new__(self, lines: BaseMultipartGeometry | Collection[_ConvertibleToLineString] | None = None) -> Self: ...
|
||||
def svg(self, scale_factor: float = 1.0, stroke_color: str | None = None, opacity: float | None = None) -> str: ... # type: ignore[override]
|
||||
# more precise base overrides
|
||||
|
||||
@@ -13,6 +13,7 @@ class MultiPoint(BaseMultipartGeometry[Point]):
|
||||
# * `Sequence` is more correct but it will lead to False positives with common types
|
||||
# like np.ndarray, pd.Index, pd.Series, ...
|
||||
# I went with Collection as false negatives seem better to me than false positives in this case
|
||||
__slots__: list[str] = []
|
||||
def __new__(self, points: MultiPoint | Collection[_PointLike] | None = None) -> Self: ...
|
||||
def svg(self, scale_factor: float = 1.0, fill_color: str | None = None, opacity: float | None = None) -> str: ... # type: ignore[override]
|
||||
# more precise base overrides
|
||||
|
||||
@@ -8,6 +8,7 @@ from .polygon import Polygon, _PolygonHolesLike, _PolygonShellLike
|
||||
__all__ = ["MultiPolygon"]
|
||||
|
||||
class MultiPolygon(BaseMultipartGeometry[Polygon]):
|
||||
__slots__: list[str] = []
|
||||
def __new__(
|
||||
self,
|
||||
polygons: (
|
||||
|
||||
@@ -11,6 +11,7 @@ __all__ = ["Point"]
|
||||
_PointLike: TypeAlias = Point | Iterable[float] | ArrayLikeSeq[float]
|
||||
|
||||
class Point(BaseGeometry):
|
||||
__slots__: list[str] = []
|
||||
@overload # no args: empty point
|
||||
def __new__(self) -> Self: ...
|
||||
@overload # one arg: (x, y[, z]) tuple or a Point instance
|
||||
|
||||
@@ -13,6 +13,7 @@ _PolygonShellLike: TypeAlias = Polygon | _ConvertibleToLinearRing | None
|
||||
_PolygonHolesLike: TypeAlias = Collection[_ConvertibleToLinearRing | None] | None
|
||||
|
||||
class LinearRing(LineString):
|
||||
__slots__: list[str] = []
|
||||
def __new__(self, coordinates: _ConvertibleToLinearRing | None = None) -> Self: ...
|
||||
@property
|
||||
def is_ccw(self) -> bool: ...
|
||||
@@ -28,6 +29,7 @@ class InteriorRingSequence:
|
||||
def __getitem__(self, key: slice) -> list[LinearRing]: ...
|
||||
|
||||
class Polygon(BaseGeometry):
|
||||
__slots__: list[str] = []
|
||||
def __new__(self, shell: _PolygonShellLike = None, holes: _PolygonHolesLike = None) -> Self: ...
|
||||
@property
|
||||
def exterior(self) -> LinearRing: ...
|
||||
|
||||
Reference in New Issue
Block a user