Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
StefanBrand opened this issue Jan 23, 2023 · 3 comments · Fixed by #1335
Closed

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

StefanBrand opened this issue Jan 23, 2023 · 3 comments · Fixed by #1335
Labels
bug Something isn't working regression Behavior has changed for worse with a release stubs Issues in stubs files (.pyi)

Comments

@StefanBrand
Copy link

StefanBrand commented Jan 23, 2023

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
@StefanBrand StefanBrand added the bug Something isn't working label Jan 23, 2023
@intgr
Copy link
Collaborator

intgr commented Jan 23, 2023

If you're up for it, for simple changes like this, you could also try submitting a PR.

@intgr intgr added stubs Issues in stubs files (.pyi) regression Behavior has changed for worse with a release labels Jan 23, 2023
@intgr
Copy link
Collaborator

intgr commented Jan 23, 2023

ciscorn already added this to the existing PR. 👍

@StefanBrand
Copy link
Author

If you're up for it, for simple changes like this, you could also try submitting a PR.

Cool, I'll keep it in mind in case I find something else. I've seen that this one is already covered in #1335

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Behavior has changed for worse with a release stubs Issues in stubs files (.pyi)
Development

Successfully merging a pull request may close this issue.

2 participants