Skip to content

error: "bytes" has no attribute "tobytes"  #1336

@StefanBrand

Description

@StefanBrand

Bug report

What's wrong

mypy: error: "bytes" has no attribute "tobytes"

Contrary to shapely.LineString the wkb property of django.contrib.gis.geos.LineString is not of type bytes, but of type memoryview.

>>> type(geometry.boundary)
<class 'django.contrib.gis.geos.collections.MultiLineString'>
>>> type(geometry.boundary.wkb)
<class 'memoryview'>
>>> type(geometry.boundary.wkb.tobytes())
<class 'bytes'>

@property
def wkb(self) -> bytes: ...

How is that should be

Probably:

 @property 
 def wkb(self) -> memoryview: ... 

cc @ciscorn

Background information:

System information

  • OS: Docker image python:3.9.16-bullseye
  • python version: 3.9.16
  • django version: 4.1.4
  • mypy version: 0-991
  • django-stubs version: 1.13.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingregressionBehavior has changed for worse with a releasestubsIssues in stubs files (.pyi)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions