Comments (4)
It has been some what annoying so far having to look back and forth between the documentation/api and my code just to know what returns and what methods the skia package gives. Will there be a fix for this soon?
from skia-python.
I tried pybind11-stubgen
and mypy's stubgen
from the issue description. I'll share some findings here even though I haven't figured out a working solution for everyone.
pybind11-stubgen skia
didn't generate stubs due to errors.
$ pip install pybind11-stubgen
$ pybind11-stubgen skia
[2022-03-13 17:12:47,680] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,680] {__init__.py:135} ERROR - def search(self: skia.BBoxHierarchy, query: skia.Rect, results: std::__1::vector<int, std::__1::allocator<int> >) -> None: ...
[2022-03-13 17:12:47,680] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:47,713] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,713] {__init__.py:135} ERROR - def drawLine(self: skia.Canvas, x0: float, y0: float, x1: float, y1`: float, paint: skia.Paint) -> None: ...
[2022-03-13 17:12:47,714] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:47,875] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,875] {__init__.py:135} ERROR - def queryYUVAInfo(self: skia.Codec, supportedDataTypes: SkYUVAPixmapInfo::SupportedDataTypes) -> object: ...
[2022-03-13 17:12:47,875] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:47,903] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,903] {__init__.py:135} ERROR - def page(self: skia.Document, width: float, height: float) -> : ...
[2022-03-13 17:12:47,903] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:47,946] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,946] {__init__.py:135} ERROR - def MakeMock(colorType: skia.GrColorType, compression: SkImage::CompressionType) -> skia.GrBackendFormat: ...
[2022-03-13 17:12:47,946] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:47,947] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,947] {__init__.py:135} ERROR - def asMockCompressionType(self: skia.GrBackendFormat) -> SkImage::CompressionType: ...
[2022-03-13 17:12:47,947] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:47,957] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,957] {__init__.py:135} ERROR - def compressedBackendFormat(self: skia.GrContext, compressionType: SkImage::CompressionType) -> skia.GrBackendFormat: ...
[2022-03-13 17:12:47,957] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:47,958] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,958] {__init__.py:135} ERROR - def createCompressedBackendTexture(self: skia.GrContext, width: int, height: int, type: SkImage::CompressionType, color: skia.Color4f, mipMapped: skia.GrMipmapped, isProtected: skia.GrProtected = GrProtected.kNo) -> skia.GrBackendTexture: ...
[2022-03-13 17:12:47,958] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:47,958] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,958] {__init__.py:135} ERROR - def createCompressedBackendTexture(self: skia.GrContext, width: int, height: int, type: SkImage::CompressionType, data: buffer, mipMapped: skia.GrMipmapped, isProtected: skia.GrProtected = GrProtected.kNo) -> skia.GrBackendTexture: ...
[2022-03-13 17:12:47,958] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:47,967] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,967] {__init__.py:135} ERROR - def compressedBackendFormat(self: skia.GrContext_Base, arg0: SkImage::CompressionType) -> skia.GrBackendFormat: ...
[2022-03-13 17:12:47,967] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:47,971] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,971] {__init__.py:135} ERROR - def __init__(self: skia.GrMockTextureInfo, colorType: skia.GrColorType, compressionType: SkImage::CompressionType, id: int) -> None: ...
[2022-03-13 17:12:47,971] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:47,971] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:47,972] {__init__.py:135} ERROR - def compressionType(self: skia.GrMockTextureInfo) -> SkImage::CompressionType: ...
[2022-03-13 17:12:47,972] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:48,001] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:48,001] {__init__.py:135} ERROR - def MakeFromNV12TexturesCopy(context: skia.GrContext, yuvColorSpace: skia.YUVColorSpace, nv12Textures: std::__1::vector<GrBackendTexture, std::__1::allocator<GrBackendTexture> >, imageOrigin: skia.GrSurfaceOrigin, imageColorSpace: skia.ColorSpace = None) -> skia.Image: ...
[2022-03-13 17:12:48,001] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:48,001] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:48,002] {__init__.py:135} ERROR - def MakeFromNV12TexturesCopyWithExternalBackend(context: skia.GrContext, yuvColorSpace: skia.YUVColorSpace, nv12Textures: std::__1::vector<GrBackendTexture, std::__1::allocator<GrBackendTexture> >, imageOrigin: skia.GrSurfaceOrigin, backendTexture: skia.GrBackendTexture, imageColorSpace: skia.ColorSpace = None) -> skia.Image: ...
[2022-03-13 17:12:48,002] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:48,009] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:48,009] {__init__.py:135} ERROR - def MakeFromYUVAPixmaps(context: skia.GrRecordingContext, yuvaPixmaps: skia.YUVColorSpace, yuvaTextures: std::__1::vector<SkPixmap, std::__1::allocator<SkPixmap> >, yuvaIndices: std::__1::vector<SkYUVAIndex, std::__1::allocator<SkYUVAIndex> >, imageSize: skia.ISize, imageOrigin: skia.GrSurfaceOrigin, buildMips: bool, limitToMaxTextureSize: bool = False, imageColorSpace: skia.ColorSpace = None) -> skia.Image: ...
[2022-03-13 17:12:48,009] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:48,010] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:48,010] {__init__.py:135} ERROR - def MakeFromYUVATextures(context: skia.GrContext, yuvColorSpace: skia.YUVColorSpace, yuvaTextures: std::__1::vector<GrBackendTexture, std::__1::allocator<GrBackendTexture> >, yuvaIndices: std::__1::vector<SkYUVAIndex, std::__1::allocator<SkYUVAIndex> >, imageSize: skia.ISize, imageOrigin: skia.GrSurfaceOrigin, imageColorSpace: skia.ColorSpace = None) -> skia.Image: ...
[2022-03-13 17:12:48,010] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:48,011] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:48,011] {__init__.py:135} ERROR - def MakeFromYUVATexturesCopy(context: skia.GrRecordingContext, yuvColorSpace: skia.YUVColorSpace, yuvaTextures: std::__1::vector<GrBackendTexture, std::__1::allocator<GrBackendTexture> >, yuvaIndices: std::__1::vector<SkYUVAIndex, std::__1::allocator<SkYUVAIndex> >, imageSize: skia.ISize, imageOrigin: skia.GrSurfaceOrigin, imageColorSpace: skia.ColorSpace = None) -> skia.Image: ...
[2022-03-13 17:12:48,011] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:48,011] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:48,011] {__init__.py:135} ERROR - def MakeFromYUVATexturesCopyWithExternalBackend(context: skia.GrRecordingContext, yuvColorSpace: skia.YUVColorSpace, yuvaTextures: std::__1::vector<GrBackendTexture, std::__1::allocator<GrBackendTexture> >, yuvaIndices: std::__1::vector<SkYUVAIndex, std::__1::allocator<SkYUVAIndex> >, imageSize: skia.ISize, imageOrigin: skia.GrSurfaceOrigin, backendTexture: skia.GrBackendTexture, imageColorSpace: skia.ColorSpace = None) -> skia.Image: ...
[2022-03-13 17:12:48,011] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:48,177] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:48,177] {__init__.py:135} ERROR - def Offset(points: std::__1::vector<SkPoint, std::__1::allocator<SkPoint> >, offset: skia.Point) -> std::__1::vector<SkPoint, std::__1::allocator<SkPoint> >: ...
[2022-03-13 17:12:48,177] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:48,177] {__init__.py:131} ERROR - Generated stubs signature is degraded to `(*args, **kwargs) -> typing.Any` for
[2022-03-13 17:12:48,177] {__init__.py:135} ERROR - def Offset(points: std::__1::vector<SkPoint, std::__1::allocator<SkPoint> >, dx: float, dy: float) -> std::__1::vector<SkPoint, std::__1::allocator<SkPoint> >: ...
[2022-03-13 17:12:48,177] {__init__.py:136} ERROR - ^-- Invalid syntax
[2022-03-13 17:12:48,321] {__init__.py:957} INFO - Useful link: Avoiding C++ types in docstrings:
[2022-03-13 17:12:48,321] {__init__.py:958} INFO - https://pybind11.readthedocs.io/en/latest/advanced/misc.html#avoiding-cpp-types-in-docstrings
stubgen
looks more promising (sizmailov/pybind11-stubgen#31). I was able to generate type stubs that work more or less. I ran the following in my project root directory:
pip install mypy skia
stubgen -p skia -o . # Generates stubs in `./skia`
touch skia/py.typed # https://peps.python.org/pep-0561/
sed -i '' 's/Sk//g' skia/__init__.pyi # Removes the Sk prefix
The generated skia
directory contains type stubs for skia
. It could be put anywhere in sys.path
like your project root or site-packages
.
Now I got type stubs that are somewhat useful for autocompletion and basic type check, but they still have many issues:
- a field called
def
: I just commented it out... - Static methods are generated as instance methods: I manually added
@staticmethod
and removed the first argument of the ones that I use, but this is not a scalable solution. - Many many
Any
I hope this helps for someone who's willing to investigate it further.
from skia-python.
Yes, this would be great
from skia-python.
Intellisense/autocomplete doesnt work for me as well when working with the skia-python package on vscode .. please fix this probleme
from skia-python.
Related Issues (20)
- Raspberry Pi 4 Support (linux 32-bit arm) HOT 8
- Newer system gets an extra skip on exit in testing HOT 2
- AttributeError: 'skia.Paint' object has no attribute 'setTextScaleX' HOT 1
- How to underline and strikethrough fonts? HOT 4
- Binding the skparagraph module
- Mac font is thicker than Linux font HOT 3
- Missing `skia.TableColorFilter.MakeARGB` equivalent in latest builds HOT 9
- deprecation of `distutils`upstream for python >= 3.12 HOT 8
- m122: SkFontMgr::RefDefault() has been deleted HOT 5
- Is there a way to use skia.Surface to export high quality images? HOT 5
- Missing `getBlendMode` on `skia.Paint` objects HOT 7
- "instance = class() ; instance.initGL()" vs "instance = class.MakeGL()
- rgb r and b are working in reverse fashion... HOT 1
- rgb r and b are working in reverse fashion... HOT 1
- Improve SamplingOptions, and adding test cases HOT 7
- Identify what breaks in m122 for font(typeface("")) on mac os HOT 7
- Support for Python 3.12 HOT 2
- Build for python3.21 HOT 1
- "Shader Compilation Error" HOT 12
- python3.7 could not pip install skia-python HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skia-python.