From 95b55519895d371473c2810b14860b5a636fdeea Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Mon, 25 Nov 2024 12:53:07 +0100 Subject: [PATCH] New ruff (#648) * New ruff * codegen must produce sorted __all__ --- codegen/apipatcher.py | 2 +- codegen/apiwriter.py | 6 +-- wgpu/_classes.py | 56 ++++++++++++------------- wgpu/enums.py | 52 +++++++++++------------ wgpu/flags.py | 4 +- wgpu/gui/__init__.py | 4 +- wgpu/gui/auto.py | 2 +- wgpu/structs.py | 96 +++++++++++++++++++++---------------------- 8 files changed, 111 insertions(+), 111 deletions(-) diff --git a/codegen/apipatcher.py b/codegen/apipatcher.py index 5449cbda..3acd0859 100644 --- a/codegen/apipatcher.py +++ b/codegen/apipatcher.py @@ -44,7 +44,7 @@ def patch_base_api(code): if found_all: part2 = part2.split("]", 1)[-1] line = "\n__all__ = [" - line += ", ".join(f'"{name}"' for name in idl.classes.keys()) + line += ", ".join(f'"{name}"' for name in sorted(idl.classes.keys())) line += "]" code = part1 + line + part2 diff --git a/codegen/apiwriter.py b/codegen/apiwriter.py index 798e30da..8656776f 100644 --- a/codegen/apiwriter.py +++ b/codegen/apiwriter.py @@ -48,7 +48,7 @@ def write_flags(): # List'm pylines.append(f"# There are {n} flags\n") pylines.append("__all__ = [") - for name in idl.flags.keys(): + for name in sorted(idl.flags.keys()): pylines.append(f' "{name}",') pylines.append("]\n\n") # The flags definitions @@ -78,7 +78,7 @@ def write_enums(): # List'm pylines.append(f"# There are {n} enums\n") pylines.append("__all__ = [") - for name in idl.enums.keys(): + for name in sorted(idl.enums.keys()): pylines.append(f' "{name}",') pylines.append("]\n\n") for name, d in idl.enums.items(): @@ -108,7 +108,7 @@ def write_structs(): pylines.append(f"# There are {n} structs\n") # List'm pylines.append("__all__ = [") - for name in idl.structs.keys(): + for name in sorted(idl.structs.keys()): if name not in ignore: pylines.append(f' "{name}",') pylines.append("]\n\n") diff --git a/wgpu/_classes.py b/wgpu/_classes.py index 688670e8..e9b380bc 100644 --- a/wgpu/_classes.py +++ b/wgpu/_classes.py @@ -21,43 +21,43 @@ __all__ = [ - "GPUObjectBase", - "GPUAdapterInfo", "GPU", "GPUAdapter", - "GPUDevice", - "GPUBuffer", - "GPUTexture", - "GPUTextureView", - "GPUSampler", - "GPUBindGroupLayout", + "GPUAdapterInfo", "GPUBindGroup", - "GPUPipelineLayout", - "GPUShaderModule", - "GPUCompilationMessage", - "GPUCompilationInfo", - "GPUPipelineError", - "GPUPipelineBase", - "GPUComputePipeline", - "GPURenderPipeline", + "GPUBindGroupLayout", + "GPUBindingCommandsMixin", + "GPUBuffer", + "GPUCanvasContext", "GPUCommandBuffer", - "GPUCommandsMixin", "GPUCommandEncoder", - "GPUBindingCommandsMixin", - "GPUDebugCommandsMixin", + "GPUCommandsMixin", + "GPUCompilationInfo", + "GPUCompilationMessage", "GPUComputePassEncoder", - "GPURenderPassEncoder", - "GPURenderCommandsMixin", - "GPURenderBundle", - "GPURenderBundleEncoder", - "GPUQueue", - "GPUQuerySet", - "GPUCanvasContext", + "GPUComputePipeline", + "GPUDebugCommandsMixin", + "GPUDevice", "GPUDeviceLostInfo", "GPUError", - "GPUValidationError", - "GPUOutOfMemoryError", "GPUInternalError", + "GPUObjectBase", + "GPUOutOfMemoryError", + "GPUPipelineBase", + "GPUPipelineError", + "GPUPipelineLayout", + "GPUQuerySet", + "GPUQueue", + "GPURenderBundle", + "GPURenderBundleEncoder", + "GPURenderCommandsMixin", + "GPURenderPassEncoder", + "GPURenderPipeline", + "GPUSampler", + "GPUShaderModule", + "GPUTexture", + "GPUTextureView", + "GPUValidationError", ] logger = logging.getLogger("wgpu") diff --git a/wgpu/enums.py b/wgpu/enums.py index 75ea9ad2..ecfe47f0 100644 --- a/wgpu/enums.py +++ b/wgpu/enums.py @@ -21,40 +21,40 @@ class Enum(_BaseEnum): # There are 34 enums __all__ = [ - "PowerPreference", - "FeatureName", - "BufferMapState", - "TextureDimension", - "TextureViewDimension", - "TextureAspect", - "TextureFormat", "AddressMode", - "FilterMode", - "MipmapFilterMode", - "CompareFunction", - "BufferBindingType", - "SamplerBindingType", - "TextureSampleType", - "StorageTextureAccess", - "CompilationMessageType", - "PipelineErrorReason", "AutoLayoutMode", - "PrimitiveTopology", - "FrontFace", - "CullMode", "BlendFactor", "BlendOperation", - "StencilOperation", - "IndexFormat", - "VertexFormat", - "VertexStepMode", - "LoadOp", - "StoreOp", - "QueryType", + "BufferBindingType", + "BufferMapState", "CanvasAlphaMode", "CanvasToneMappingMode", + "CompareFunction", + "CompilationMessageType", + "CullMode", "DeviceLostReason", "ErrorFilter", + "FeatureName", + "FilterMode", + "FrontFace", + "IndexFormat", + "LoadOp", + "MipmapFilterMode", + "PipelineErrorReason", + "PowerPreference", + "PrimitiveTopology", + "QueryType", + "SamplerBindingType", + "StencilOperation", + "StorageTextureAccess", + "StoreOp", + "TextureAspect", + "TextureDimension", + "TextureFormat", + "TextureSampleType", + "TextureViewDimension", + "VertexFormat", + "VertexStepMode", ] diff --git a/wgpu/flags.py b/wgpu/flags.py index 5bd06793..7fa73a18 100644 --- a/wgpu/flags.py +++ b/wgpu/flags.py @@ -23,10 +23,10 @@ class Flags(_BaseEnum): __all__ = [ "BufferUsage", + "ColorWrite", "MapMode", - "TextureUsage", "ShaderStage", - "ColorWrite", + "TextureUsage", ] diff --git a/wgpu/gui/__init__.py b/wgpu/gui/__init__.py index cb74d27e..c35d54cd 100644 --- a/wgpu/gui/__init__.py +++ b/wgpu/gui/__init__.py @@ -6,7 +6,7 @@ from .base import WgpuCanvasInterface, WgpuCanvasBase, WgpuAutoGui __all__ = [ - "WgpuCanvasInterface", - "WgpuCanvasBase", "WgpuAutoGui", + "WgpuCanvasBase", + "WgpuCanvasInterface", ] diff --git a/wgpu/gui/auto.py b/wgpu/gui/auto.py index 65536ec1..a3a11178 100644 --- a/wgpu/gui/auto.py +++ b/wgpu/gui/auto.py @@ -5,7 +5,7 @@ for e.g. wx later. Or we might decide to stick with these three. """ -__all__ = ["WgpuCanvas", "run", "call_later"] +__all__ = ["WgpuCanvas", "call_later", "run"] import os import sys diff --git a/wgpu/structs.py b/wgpu/structs.py index cd2d3707..857a34c7 100644 --- a/wgpu/structs.py +++ b/wgpu/structs.py @@ -30,65 +30,65 @@ def __repr__(self): # There are 60 structs __all__ = [ - "RequestAdapterOptions", - "DeviceDescriptor", - "BufferDescriptor", - "TextureDescriptor", - "TextureViewDescriptor", - "ExternalTextureDescriptor", - "SamplerDescriptor", - "BindGroupLayoutDescriptor", - "BindGroupLayoutEntry", - "BufferBindingLayout", - "SamplerBindingLayout", - "TextureBindingLayout", - "StorageTextureBindingLayout", - "ExternalTextureBindingLayout", "BindGroupDescriptor", "BindGroupEntry", + "BindGroupLayoutDescriptor", + "BindGroupLayoutEntry", + "BlendComponent", + "BlendState", "BufferBinding", - "PipelineLayoutDescriptor", - "ShaderModuleDescriptor", - "ShaderModuleCompilationHint", - "PipelineErrorInit", - "ProgrammableStage", - "ComputePipelineDescriptor", - "RenderPipelineDescriptor", - "PrimitiveState", - "MultisampleState", - "FragmentState", + "BufferBindingLayout", + "BufferDescriptor", + "CanvasConfiguration", + "CanvasToneMapping", + "Color", "ColorTargetState", - "BlendState", - "BlendComponent", - "DepthStencilState", - "StencilFaceState", - "VertexState", - "VertexBufferLayout", - "VertexAttribute", - "ImageDataLayout", - "ImageCopyBuffer", - "ImageCopyTexture", - "ImageCopyExternalImage", "CommandBufferDescriptor", "CommandEncoderDescriptor", - "ComputePassTimestampWrites", "ComputePassDescriptor", - "RenderPassTimestampWrites", - "RenderPassDescriptor", + "ComputePassTimestampWrites", + "ComputePipelineDescriptor", + "DepthStencilState", + "DeviceDescriptor", + "Extent3D", + "ExternalTextureBindingLayout", + "ExternalTextureDescriptor", + "FragmentState", + "ImageCopyBuffer", + "ImageCopyExternalImage", + "ImageCopyTexture", + "ImageDataLayout", + "MultisampleState", + "Origin2D", + "Origin3D", + "PipelineErrorInit", + "PipelineLayoutDescriptor", + "PrimitiveState", + "ProgrammableStage", + "QuerySetDescriptor", + "QueueDescriptor", + "RenderBundleDescriptor", + "RenderBundleEncoderDescriptor", "RenderPassColorAttachment", "RenderPassDepthStencilAttachment", + "RenderPassDescriptor", "RenderPassLayout", - "RenderBundleDescriptor", - "RenderBundleEncoderDescriptor", - "QueueDescriptor", - "QuerySetDescriptor", - "CanvasToneMapping", - "CanvasConfiguration", + "RenderPassTimestampWrites", + "RenderPipelineDescriptor", + "RequestAdapterOptions", + "SamplerBindingLayout", + "SamplerDescriptor", + "ShaderModuleCompilationHint", + "ShaderModuleDescriptor", + "StencilFaceState", + "StorageTextureBindingLayout", + "TextureBindingLayout", + "TextureDescriptor", + "TextureViewDescriptor", "UncapturedErrorEventInit", - "Color", - "Origin2D", - "Origin3D", - "Extent3D", + "VertexAttribute", + "VertexBufferLayout", + "VertexState", ]