From 99430267b178ed371fbbc76c841def1ca7785f8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 18:27:32 -0800 Subject: [PATCH] chore(deps): bump ruff from 0.2.1 to 0.3.0 in /requirements/lintrunner (#1287) --- docs/examples/01_plot_selu.py | 1 - .../examples/04_plot_eager_mode_evaluation.py | 1 + onnxscript/_internal/ast_utils.py | 1 + onnxscript/_internal/param_manipulation.py | 1 + onnxscript/_internal/runtime_typing.py | 1 + .../infra/sarif/_artifact_content.py | 6 +-- .../diagnostics/infra/sarif/_conversion.py | 8 ++-- .../infra/sarif/_external_properties.py | 8 ++-- .../_external_property_file_references.py | 18 ++++---- .../diagnostics/infra/sarif/_invocation.py | 20 ++++----- .../diagnostics/infra/sarif/_location.py | 6 +-- .../diagnostics/infra/sarif/_notification.py | 12 +++--- .../infra/sarif/_reporting_descriptor.py | 20 ++++----- .../sarif/_reporting_descriptor_reference.py | 6 +-- onnxscript/diagnostics/infra/sarif/_result.py | 24 +++++------ .../infra/sarif/_result_provenance.py | 6 +-- onnxscript/diagnostics/infra/sarif/_run.py | 20 ++++----- .../diagnostics/infra/sarif/_sarif_log.py | 8 ++-- .../infra/sarif/_thread_flow_location.py | 6 +-- .../infra/sarif/_tool_component.py | 42 +++++++++---------- .../infra/sarif/_translation_metadata.py | 12 +++--- .../torch_lib/deduce_type_constraints_test.py | 1 + .../torch_lib/generate_aten_signatures.py | 1 + .../torch_lib/generate_prims_signatures.py | 1 + .../function_libs/torch_lib/graph_building.py | 13 +++--- .../torch_lib/graph_building_test.py | 1 + .../function_libs/torch_lib/ops/core.py | 1 + onnxscript/function_libs/torch_lib/ops/fft.py | 1 + .../function_libs/torch_lib/ops/linalg.py | 1 + .../function_libs/torch_lib/ops/nested.py | 1 + .../function_libs/torch_lib/ops/prims.py | 1 + .../function_libs/torch_lib/ops/sparse.py | 1 + .../function_libs/torch_lib/ops/special.py | 1 + .../function_libs/torch_lib/ops/vision.py | 1 + .../tests/function_libs/torch_lib/ops_test.py | 1 + .../function_libs/torch_lib/ops_test_data.py | 1 + onnxscript/tests/onnx_types_test.py | 1 + onnxscript/values.py | 12 ++---- requirements/lintrunner/requirements.txt | 2 +- setup.py | 6 +-- 40 files changed, 145 insertions(+), 130 deletions(-) diff --git a/docs/examples/01_plot_selu.py b/docs/examples/01_plot_selu.py index 5f245fe1c..1cf14975b 100644 --- a/docs/examples/01_plot_selu.py +++ b/docs/examples/01_plot_selu.py @@ -5,7 +5,6 @@ The example below shows how we can define Selu as a function in onnxscript. """ - # %% # First, import the ONNX opset used to define the function. from onnxscript import opset15 as op diff --git a/docs/examples/04_plot_eager_mode_evaluation.py b/docs/examples/04_plot_eager_mode_evaluation.py index 63a7bba6e..740e2275a 100644 --- a/docs/examples/04_plot_eager_mode_evaluation.py +++ b/docs/examples/04_plot_eager_mode_evaluation.py @@ -10,6 +10,7 @@ The example below illustrates this. We first define an *onnxscript* function: """ + import numpy as np from onnxscript import FLOAT, script diff --git a/onnxscript/_internal/ast_utils.py b/onnxscript/_internal/ast_utils.py index 57a224046..974ae75a0 100644 --- a/onnxscript/_internal/ast_utils.py +++ b/onnxscript/_internal/ast_utils.py @@ -1,4 +1,5 @@ """Utilities for working with Python ASTs.""" + from __future__ import annotations import ast diff --git a/onnxscript/_internal/param_manipulation.py b/onnxscript/_internal/param_manipulation.py index ae625c3ae..54593abf3 100644 --- a/onnxscript/_internal/param_manipulation.py +++ b/onnxscript/_internal/param_manipulation.py @@ -1,4 +1,5 @@ """Function for manipulating input parameters of an Op or a OnnxFunction.""" + from __future__ import annotations import collections diff --git a/onnxscript/_internal/runtime_typing.py b/onnxscript/_internal/runtime_typing.py index 56796a7bd..fc4ea9f79 100644 --- a/onnxscript/_internal/runtime_typing.py +++ b/onnxscript/_internal/runtime_typing.py @@ -4,6 +4,7 @@ type checking. The decorator is a no-op when the `beartype` library is not installed. """ + import warnings __all__ = [ diff --git a/onnxscript/diagnostics/infra/sarif/_artifact_content.py b/onnxscript/diagnostics/infra/sarif/_artifact_content.py index fc69c9d8a..403806619 100644 --- a/onnxscript/diagnostics/infra/sarif/_artifact_content.py +++ b/onnxscript/diagnostics/infra/sarif/_artifact_content.py @@ -22,9 +22,9 @@ class ArtifactContent: properties: Optional[_property_bag.PropertyBag] = dataclasses.field( default=None, metadata={"schema_property_name": "properties"} ) - rendered: Optional[ - _multiformat_message_string.MultiformatMessageString - ] = dataclasses.field(default=None, metadata={"schema_property_name": "rendered"}) + rendered: Optional[_multiformat_message_string.MultiformatMessageString] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "rendered"}) + ) text: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "text"} ) diff --git a/onnxscript/diagnostics/infra/sarif/_conversion.py b/onnxscript/diagnostics/infra/sarif/_conversion.py index 072046de5..6078c525f 100644 --- a/onnxscript/diagnostics/infra/sarif/_conversion.py +++ b/onnxscript/diagnostics/infra/sarif/_conversion.py @@ -19,10 +19,10 @@ class Conversion: """Describes how a converter transformed the output of a static analysis tool from the analysis tool's native output format into the SARIF format.""" tool: _tool.Tool = dataclasses.field(metadata={"schema_property_name": "tool"}) - analysis_tool_log_files: Optional[ - List[_artifact_location.ArtifactLocation] - ] = dataclasses.field( - default=None, metadata={"schema_property_name": "analysisToolLogFiles"} + analysis_tool_log_files: Optional[List[_artifact_location.ArtifactLocation]] = ( + dataclasses.field( + default=None, metadata={"schema_property_name": "analysisToolLogFiles"} + ) ) invocation: Optional[_invocation.Invocation] = dataclasses.field( default=None, metadata={"schema_property_name": "invocation"} diff --git a/onnxscript/diagnostics/infra/sarif/_external_properties.py b/onnxscript/diagnostics/infra/sarif/_external_properties.py index 884bdeb17..d63a16aff 100644 --- a/onnxscript/diagnostics/infra/sarif/_external_properties.py +++ b/onnxscript/diagnostics/infra/sarif/_external_properties.py @@ -74,10 +74,10 @@ class ExternalProperties: taxonomies: Optional[List[_tool_component.ToolComponent]] = dataclasses.field( default=None, metadata={"schema_property_name": "taxonomies"} ) - thread_flow_locations: Optional[ - List[_thread_flow_location.ThreadFlowLocation] - ] = dataclasses.field( - default=None, metadata={"schema_property_name": "threadFlowLocations"} + thread_flow_locations: Optional[List[_thread_flow_location.ThreadFlowLocation]] = ( + dataclasses.field( + default=None, metadata={"schema_property_name": "threadFlowLocations"} + ) ) translations: Optional[List[_tool_component.ToolComponent]] = dataclasses.field( default=None, metadata={"schema_property_name": "translations"} diff --git a/onnxscript/diagnostics/infra/sarif/_external_property_file_references.py b/onnxscript/diagnostics/infra/sarif/_external_property_file_references.py index be4e12537..d596a7a87 100644 --- a/onnxscript/diagnostics/infra/sarif/_external_property_file_references.py +++ b/onnxscript/diagnostics/infra/sarif/_external_property_file_references.py @@ -22,12 +22,12 @@ class ExternalPropertyFileReferences: artifacts: Optional[ List[_external_property_file_reference.ExternalPropertyFileReference] ] = dataclasses.field(default=None, metadata={"schema_property_name": "artifacts"}) - conversion: Optional[ - _external_property_file_reference.ExternalPropertyFileReference - ] = dataclasses.field(default=None, metadata={"schema_property_name": "conversion"}) - driver: Optional[ - _external_property_file_reference.ExternalPropertyFileReference - ] = dataclasses.field(default=None, metadata={"schema_property_name": "driver"}) + conversion: Optional[_external_property_file_reference.ExternalPropertyFileReference] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "conversion"}) + ) + driver: Optional[_external_property_file_reference.ExternalPropertyFileReference] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "driver"}) + ) extensions: Optional[ List[_external_property_file_reference.ExternalPropertyFileReference] ] = dataclasses.field(default=None, metadata={"schema_property_name": "extensions"}) @@ -36,9 +36,9 @@ class ExternalPropertyFileReferences: ] = dataclasses.field( default=None, metadata={"schema_property_name": "externalizedProperties"} ) - graphs: Optional[ - List[_external_property_file_reference.ExternalPropertyFileReference] - ] = dataclasses.field(default=None, metadata={"schema_property_name": "graphs"}) + graphs: Optional[List[_external_property_file_reference.ExternalPropertyFileReference]] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "graphs"}) + ) invocations: Optional[ List[_external_property_file_reference.ExternalPropertyFileReference] ] = dataclasses.field(default=None, metadata={"schema_property_name": "invocations"}) diff --git a/onnxscript/diagnostics/infra/sarif/_invocation.py b/onnxscript/diagnostics/infra/sarif/_invocation.py index 041581c30..6f96c9a86 100644 --- a/onnxscript/diagnostics/infra/sarif/_invocation.py +++ b/onnxscript/diagnostics/infra/sarif/_invocation.py @@ -92,16 +92,16 @@ class Invocation: stdout_stderr: Optional[_artifact_location.ArtifactLocation] = dataclasses.field( default=None, metadata={"schema_property_name": "stdoutStderr"} ) - tool_configuration_notifications: Optional[ - List[_notification.Notification] - ] = dataclasses.field( - default=None, - metadata={"schema_property_name": "toolConfigurationNotifications"}, - ) - tool_execution_notifications: Optional[ - List[_notification.Notification] - ] = dataclasses.field( - default=None, metadata={"schema_property_name": "toolExecutionNotifications"} + tool_configuration_notifications: Optional[List[_notification.Notification]] = ( + dataclasses.field( + default=None, + metadata={"schema_property_name": "toolConfigurationNotifications"}, + ) + ) + tool_execution_notifications: Optional[List[_notification.Notification]] = ( + dataclasses.field( + default=None, metadata={"schema_property_name": "toolExecutionNotifications"} + ) ) working_directory: Optional[_artifact_location.ArtifactLocation] = dataclasses.field( default=None, metadata={"schema_property_name": "workingDirectory"} diff --git a/onnxscript/diagnostics/infra/sarif/_location.py b/onnxscript/diagnostics/infra/sarif/_location.py index c9782f091..319856f8d 100644 --- a/onnxscript/diagnostics/infra/sarif/_location.py +++ b/onnxscript/diagnostics/infra/sarif/_location.py @@ -36,9 +36,9 @@ class Location: properties: Optional[_property_bag.PropertyBag] = dataclasses.field( default=None, metadata={"schema_property_name": "properties"} ) - relationships: Optional[ - List[_location_relationship.LocationRelationship] - ] = dataclasses.field(default=None, metadata={"schema_property_name": "relationships"}) + relationships: Optional[List[_location_relationship.LocationRelationship]] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "relationships"}) + ) # flake8: noqa diff --git a/onnxscript/diagnostics/infra/sarif/_notification.py b/onnxscript/diagnostics/infra/sarif/_notification.py index 402d36b40..f41a9f8d5 100644 --- a/onnxscript/diagnostics/infra/sarif/_notification.py +++ b/onnxscript/diagnostics/infra/sarif/_notification.py @@ -20,12 +20,12 @@ class Notification: """Describes a condition relevant to the tool itself, as opposed to being relevant to a target being analyzed by the tool.""" message: _message.Message = dataclasses.field(metadata={"schema_property_name": "message"}) - associated_rule: Optional[ - _reporting_descriptor_reference.ReportingDescriptorReference - ] = dataclasses.field(default=None, metadata={"schema_property_name": "associatedRule"}) - descriptor: Optional[ - _reporting_descriptor_reference.ReportingDescriptorReference - ] = dataclasses.field(default=None, metadata={"schema_property_name": "descriptor"}) + associated_rule: Optional[_reporting_descriptor_reference.ReportingDescriptorReference] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "associatedRule"}) + ) + descriptor: Optional[_reporting_descriptor_reference.ReportingDescriptorReference] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "descriptor"}) + ) exception: Optional[_exception.Exception] = dataclasses.field( default=None, metadata={"schema_property_name": "exception"} ) diff --git a/onnxscript/diagnostics/infra/sarif/_reporting_descriptor.py b/onnxscript/diagnostics/infra/sarif/_reporting_descriptor.py index d25e9b164..85e14f376 100644 --- a/onnxscript/diagnostics/infra/sarif/_reporting_descriptor.py +++ b/onnxscript/diagnostics/infra/sarif/_reporting_descriptor.py @@ -19,10 +19,10 @@ class ReportingDescriptor: """Metadata that describes a specific report produced by the tool, as part of the analysis it provides or its runtime reporting.""" id: str = dataclasses.field(metadata={"schema_property_name": "id"}) - default_configuration: Optional[ - _reporting_configuration.ReportingConfiguration - ] = dataclasses.field( - default=None, metadata={"schema_property_name": "defaultConfiguration"} + default_configuration: Optional[_reporting_configuration.ReportingConfiguration] = ( + dataclasses.field( + default=None, metadata={"schema_property_name": "defaultConfiguration"} + ) ) deprecated_guids: Optional[List[str]] = dataclasses.field( default=None, metadata={"schema_property_name": "deprecatedGuids"} @@ -33,9 +33,9 @@ class ReportingDescriptor: deprecated_names: Optional[List[str]] = dataclasses.field( default=None, metadata={"schema_property_name": "deprecatedNames"} ) - full_description: Optional[ - _multiformat_message_string.MultiformatMessageString - ] = dataclasses.field(default=None, metadata={"schema_property_name": "fullDescription"}) + full_description: Optional[_multiformat_message_string.MultiformatMessageString] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "fullDescription"}) + ) guid: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "guid"} ) @@ -57,9 +57,9 @@ class ReportingDescriptor: relationships: Optional[ List[_reporting_descriptor_relationship.ReportingDescriptorRelationship] ] = dataclasses.field(default=None, metadata={"schema_property_name": "relationships"}) - short_description: Optional[ - _multiformat_message_string.MultiformatMessageString - ] = dataclasses.field(default=None, metadata={"schema_property_name": "shortDescription"}) + short_description: Optional[_multiformat_message_string.MultiformatMessageString] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "shortDescription"}) + ) # flake8: noqa diff --git a/onnxscript/diagnostics/infra/sarif/_reporting_descriptor_reference.py b/onnxscript/diagnostics/infra/sarif/_reporting_descriptor_reference.py index e2d0b0265..f4e6f2260 100644 --- a/onnxscript/diagnostics/infra/sarif/_reporting_descriptor_reference.py +++ b/onnxscript/diagnostics/infra/sarif/_reporting_descriptor_reference.py @@ -23,9 +23,9 @@ class ReportingDescriptorReference: properties: Optional[_property_bag.PropertyBag] = dataclasses.field( default=None, metadata={"schema_property_name": "properties"} ) - tool_component: Optional[ - _tool_component_reference.ToolComponentReference - ] = dataclasses.field(default=None, metadata={"schema_property_name": "toolComponent"}) + tool_component: Optional[_tool_component_reference.ToolComponentReference] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "toolComponent"}) + ) # flake8: noqa diff --git a/onnxscript/diagnostics/infra/sarif/_result.py b/onnxscript/diagnostics/infra/sarif/_result.py index 10f594719..3dfa564b5 100644 --- a/onnxscript/diagnostics/infra/sarif/_result.py +++ b/onnxscript/diagnostics/infra/sarif/_result.py @@ -36,9 +36,9 @@ class Result: attachments: Optional[List[_attachment.Attachment]] = dataclasses.field( default=None, metadata={"schema_property_name": "attachments"} ) - baseline_state: Optional[ - Literal["new", "unchanged", "updated", "absent"] - ] = dataclasses.field(default=None, metadata={"schema_property_name": "baselineState"}) + baseline_state: Optional[Literal["new", "unchanged", "updated", "absent"]] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "baselineState"}) + ) code_flows: Optional[List[_code_flow.CodeFlow]] = dataclasses.field( default=None, metadata={"schema_property_name": "codeFlows"} ) @@ -63,9 +63,9 @@ class Result: hosted_viewer_uri: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "hostedViewerUri"} ) - kind: Literal[ - "notApplicable", "pass", "fail", "review", "open", "informational" - ] = dataclasses.field(default="fail", metadata={"schema_property_name": "kind"}) + kind: Literal["notApplicable", "pass", "fail", "review", "open", "informational"] = ( + dataclasses.field(default="fail", metadata={"schema_property_name": "kind"}) + ) level: Literal["none", "note", "warning", "error"] = dataclasses.field( default="warning", metadata={"schema_property_name": "level"} ) @@ -88,9 +88,9 @@ class Result: related_locations: Optional[List[_location.Location]] = dataclasses.field( default=None, metadata={"schema_property_name": "relatedLocations"} ) - rule: Optional[ - _reporting_descriptor_reference.ReportingDescriptorReference - ] = dataclasses.field(default=None, metadata={"schema_property_name": "rule"}) + rule: Optional[_reporting_descriptor_reference.ReportingDescriptorReference] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "rule"}) + ) rule_id: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "ruleId"} ) @@ -103,9 +103,9 @@ class Result: suppressions: Optional[List[_suppression.Suppression]] = dataclasses.field( default=None, metadata={"schema_property_name": "suppressions"} ) - taxa: Optional[ - List[_reporting_descriptor_reference.ReportingDescriptorReference] - ] = dataclasses.field(default=None, metadata={"schema_property_name": "taxa"}) + taxa: Optional[List[_reporting_descriptor_reference.ReportingDescriptorReference]] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "taxa"}) + ) web_request: Optional[_web_request.WebRequest] = dataclasses.field( default=None, metadata={"schema_property_name": "webRequest"} ) diff --git a/onnxscript/diagnostics/infra/sarif/_result_provenance.py b/onnxscript/diagnostics/infra/sarif/_result_provenance.py index b4d489f3d..74ea9e1e9 100644 --- a/onnxscript/diagnostics/infra/sarif/_result_provenance.py +++ b/onnxscript/diagnostics/infra/sarif/_result_provenance.py @@ -13,9 +13,9 @@ class ResultProvenance: """Contains information about how and when a result was detected.""" - conversion_sources: Optional[ - List[_physical_location.PhysicalLocation] - ] = dataclasses.field(default=None, metadata={"schema_property_name": "conversionSources"}) + conversion_sources: Optional[List[_physical_location.PhysicalLocation]] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "conversionSources"}) + ) first_detection_run_guid: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "firstDetectionRunGuid"} ) diff --git a/onnxscript/diagnostics/infra/sarif/_run.py b/onnxscript/diagnostics/infra/sarif/_run.py index dca90ef75..8df4f9b57 100644 --- a/onnxscript/diagnostics/infra/sarif/_run.py +++ b/onnxscript/diagnostics/infra/sarif/_run.py @@ -38,9 +38,9 @@ class Run: artifacts: Optional[List[_artifact.Artifact]] = dataclasses.field( default=None, metadata={"schema_property_name": "artifacts"} ) - automation_details: Optional[ - _run_automation_details.RunAutomationDetails - ] = dataclasses.field(default=None, metadata={"schema_property_name": "automationDetails"}) + automation_details: Optional[_run_automation_details.RunAutomationDetails] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "automationDetails"}) + ) baseline_guid: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "baselineGuid"} ) @@ -93,19 +93,19 @@ class Run: results: Optional[List[_result.Result]] = dataclasses.field( default=None, metadata={"schema_property_name": "results"} ) - run_aggregates: Optional[ - List[_run_automation_details.RunAutomationDetails] - ] = dataclasses.field(default=None, metadata={"schema_property_name": "runAggregates"}) + run_aggregates: Optional[List[_run_automation_details.RunAutomationDetails]] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "runAggregates"}) + ) special_locations: Optional[_special_locations.SpecialLocations] = dataclasses.field( default=None, metadata={"schema_property_name": "specialLocations"} ) taxonomies: Optional[List[_tool_component.ToolComponent]] = dataclasses.field( default=None, metadata={"schema_property_name": "taxonomies"} ) - thread_flow_locations: Optional[ - List[_thread_flow_location.ThreadFlowLocation] - ] = dataclasses.field( - default=None, metadata={"schema_property_name": "threadFlowLocations"} + thread_flow_locations: Optional[List[_thread_flow_location.ThreadFlowLocation]] = ( + dataclasses.field( + default=None, metadata={"schema_property_name": "threadFlowLocations"} + ) ) translations: Optional[List[_tool_component.ToolComponent]] = dataclasses.field( default=None, metadata={"schema_property_name": "translations"} diff --git a/onnxscript/diagnostics/infra/sarif/_sarif_log.py b/onnxscript/diagnostics/infra/sarif/_sarif_log.py index 9a402f06c..aa39c52f1 100644 --- a/onnxscript/diagnostics/infra/sarif/_sarif_log.py +++ b/onnxscript/diagnostics/infra/sarif/_sarif_log.py @@ -18,10 +18,10 @@ class SarifLog: schema_uri: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "$schema"} ) - inline_external_properties: Optional[ - List[_external_properties.ExternalProperties] - ] = dataclasses.field( - default=None, metadata={"schema_property_name": "inlineExternalProperties"} + inline_external_properties: Optional[List[_external_properties.ExternalProperties]] = ( + dataclasses.field( + default=None, metadata={"schema_property_name": "inlineExternalProperties"} + ) ) properties: Optional[_property_bag.PropertyBag] = dataclasses.field( default=None, metadata={"schema_property_name": "properties"} diff --git a/onnxscript/diagnostics/infra/sarif/_thread_flow_location.py b/onnxscript/diagnostics/infra/sarif/_thread_flow_location.py index 4990104b3..949c42d80 100644 --- a/onnxscript/diagnostics/infra/sarif/_thread_flow_location.py +++ b/onnxscript/diagnostics/infra/sarif/_thread_flow_location.py @@ -49,9 +49,9 @@ class ThreadFlowLocation: default=None, metadata={"schema_property_name": "stack"} ) state: Any = dataclasses.field(default=None, metadata={"schema_property_name": "state"}) - taxa: Optional[ - List[_reporting_descriptor_reference.ReportingDescriptorReference] - ] = dataclasses.field(default=None, metadata={"schema_property_name": "taxa"}) + taxa: Optional[List[_reporting_descriptor_reference.ReportingDescriptorReference]] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "taxa"}) + ) web_request: Optional[_web_request.WebRequest] = dataclasses.field( default=None, metadata={"schema_property_name": "webRequest"} ) diff --git a/onnxscript/diagnostics/infra/sarif/_tool_component.py b/onnxscript/diagnostics/infra/sarif/_tool_component.py index e1c996893..47925ed74 100644 --- a/onnxscript/diagnostics/infra/sarif/_tool_component.py +++ b/onnxscript/diagnostics/infra/sarif/_tool_component.py @@ -21,10 +21,10 @@ class ToolComponent: """A component, such as a plug-in or the driver, of the analysis tool that was run.""" name: str = dataclasses.field(metadata={"schema_property_name": "name"}) - associated_component: Optional[ - _tool_component_reference.ToolComponentReference - ] = dataclasses.field( - default=None, metadata={"schema_property_name": "associatedComponent"} + associated_component: Optional[_tool_component_reference.ToolComponentReference] = ( + dataclasses.field( + default=None, metadata={"schema_property_name": "associatedComponent"} + ) ) contents: List[Literal["localizedData", "nonLocalizedData"]] = dataclasses.field( default_factory=lambda: ["localizedData", "nonLocalizedData"], @@ -36,9 +36,9 @@ class ToolComponent: download_uri: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "downloadUri"} ) - full_description: Optional[ - _multiformat_message_string.MultiformatMessageString - ] = dataclasses.field(default=None, metadata={"schema_property_name": "fullDescription"}) + full_description: Optional[_multiformat_message_string.MultiformatMessageString] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "fullDescription"}) + ) full_name: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "fullName"} ) @@ -67,9 +67,9 @@ class ToolComponent: default=None, metadata={"schema_property_name": "minimumRequiredLocalizedDataSemanticVersion"}, ) - notifications: Optional[ - List[_reporting_descriptor.ReportingDescriptor] - ] = dataclasses.field(default=None, metadata={"schema_property_name": "notifications"}) + notifications: Optional[List[_reporting_descriptor.ReportingDescriptor]] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "notifications"}) + ) organization: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "organization"} ) @@ -91,21 +91,21 @@ class ToolComponent: semantic_version: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "semanticVersion"} ) - short_description: Optional[ - _multiformat_message_string.MultiformatMessageString - ] = dataclasses.field(default=None, metadata={"schema_property_name": "shortDescription"}) - supported_taxonomies: Optional[ - List[_tool_component_reference.ToolComponentReference] - ] = dataclasses.field( - default=None, metadata={"schema_property_name": "supportedTaxonomies"} + short_description: Optional[_multiformat_message_string.MultiformatMessageString] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "shortDescription"}) + ) + supported_taxonomies: Optional[List[_tool_component_reference.ToolComponentReference]] = ( + dataclasses.field( + default=None, metadata={"schema_property_name": "supportedTaxonomies"} + ) ) taxa: Optional[List[_reporting_descriptor.ReportingDescriptor]] = dataclasses.field( default=None, metadata={"schema_property_name": "taxa"} ) - translation_metadata: Optional[ - _translation_metadata.TranslationMetadata - ] = dataclasses.field( - default=None, metadata={"schema_property_name": "translationMetadata"} + translation_metadata: Optional[_translation_metadata.TranslationMetadata] = ( + dataclasses.field( + default=None, metadata={"schema_property_name": "translationMetadata"} + ) ) version: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "version"} diff --git a/onnxscript/diagnostics/infra/sarif/_translation_metadata.py b/onnxscript/diagnostics/infra/sarif/_translation_metadata.py index 60e4314da..f05125a59 100644 --- a/onnxscript/diagnostics/infra/sarif/_translation_metadata.py +++ b/onnxscript/diagnostics/infra/sarif/_translation_metadata.py @@ -20,9 +20,9 @@ class TranslationMetadata: download_uri: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "downloadUri"} ) - full_description: Optional[ - _multiformat_message_string.MultiformatMessageString - ] = dataclasses.field(default=None, metadata={"schema_property_name": "fullDescription"}) + full_description: Optional[_multiformat_message_string.MultiformatMessageString] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "fullDescription"}) + ) full_name: Optional[str] = dataclasses.field( default=None, metadata={"schema_property_name": "fullName"} ) @@ -32,9 +32,9 @@ class TranslationMetadata: properties: Optional[_property_bag.PropertyBag] = dataclasses.field( default=None, metadata={"schema_property_name": "properties"} ) - short_description: Optional[ - _multiformat_message_string.MultiformatMessageString - ] = dataclasses.field(default=None, metadata={"schema_property_name": "shortDescription"}) + short_description: Optional[_multiformat_message_string.MultiformatMessageString] = ( + dataclasses.field(default=None, metadata={"schema_property_name": "shortDescription"}) + ) # flake8: noqa diff --git a/onnxscript/function_libs/tools/torch_lib/deduce_type_constraints_test.py b/onnxscript/function_libs/tools/torch_lib/deduce_type_constraints_test.py index 4e01d37ac..25586085e 100644 --- a/onnxscript/function_libs/tools/torch_lib/deduce_type_constraints_test.py +++ b/onnxscript/function_libs/tools/torch_lib/deduce_type_constraints_test.py @@ -1,4 +1,5 @@ """Test cases for type constraint deduction functionality.""" + from __future__ import annotations import inspect diff --git a/onnxscript/function_libs/tools/torch_lib/generate_aten_signatures.py b/onnxscript/function_libs/tools/torch_lib/generate_aten_signatures.py index dcc8a3b54..739959985 100644 --- a/onnxscript/function_libs/tools/torch_lib/generate_aten_signatures.py +++ b/onnxscript/function_libs/tools/torch_lib/generate_aten_signatures.py @@ -4,6 +4,7 @@ # -------------------------------------------------------------------------- """Generates the ATen signatures for the ONNX ATen operator set using torch.ops.""" + from __future__ import annotations import argparse diff --git a/onnxscript/function_libs/tools/torch_lib/generate_prims_signatures.py b/onnxscript/function_libs/tools/torch_lib/generate_prims_signatures.py index 14afeff36..e1456f2f8 100644 --- a/onnxscript/function_libs/tools/torch_lib/generate_prims_signatures.py +++ b/onnxscript/function_libs/tools/torch_lib/generate_prims_signatures.py @@ -4,6 +4,7 @@ # -------------------------------------------------------------------------- """Generates the Prims signatures for the ONNX Prims operator set using torch.ops.""" + from __future__ import annotations import argparse diff --git a/onnxscript/function_libs/torch_lib/graph_building.py b/onnxscript/function_libs/torch_lib/graph_building.py index 229b293c6..f1ace3ea7 100644 --- a/onnxscript/function_libs/torch_lib/graph_building.py +++ b/onnxscript/function_libs/torch_lib/graph_building.py @@ -1,4 +1,5 @@ """Graph building functions for torchscript graph backend.""" + from __future__ import annotations import os @@ -609,9 +610,9 @@ def add_initializer(self, name: str, value: torch.Tensor) -> TorchScriptTensor: ): # Only the root graph can have initializers. Add as initializer # to root graph, and add as input to current graph. - self._initializers_inputs_from_parent[ - name - ] = self._parent_torch_script_graph.add_initializer(name, value) + self._initializers_inputs_from_parent[name] = ( + self._parent_torch_script_graph.add_initializer(name, value) + ) else: self._initializers[name] = value @@ -957,9 +958,9 @@ def to_function_proto(self, opset_version: int, function_name: str) -> onnx.Func def to_model_proto( self, opset_version: int, include_initializers: bool = True ) -> onnx.ModelProto: - function_proto_dict: Mapping[ - Tuple[str, str], onnx.FunctionProto - ] = self.fetch_function_proto_dict(opset_version) + function_proto_dict: Mapping[Tuple[str, str], onnx.FunctionProto] = ( + self.fetch_function_proto_dict(opset_version) + ) unique_custom_domains: Dict[str, int] = {} for function_proto in function_proto_dict.values(): diff --git a/onnxscript/function_libs/torch_lib/graph_building_test.py b/onnxscript/function_libs/torch_lib/graph_building_test.py index ab8b4bc8f..3ff366d24 100644 --- a/onnxscript/function_libs/torch_lib/graph_building_test.py +++ b/onnxscript/function_libs/torch_lib/graph_building_test.py @@ -1,4 +1,5 @@ """Test cases for graph building functionality.""" + # mypy: disable-error-code="arg-type,type-arg,valid-type" from __future__ import annotations diff --git a/onnxscript/function_libs/torch_lib/ops/core.py b/onnxscript/function_libs/torch_lib/ops/core.py index 9d21cad87..7787f66da 100644 --- a/onnxscript/function_libs/torch_lib/ops/core.py +++ b/onnxscript/function_libs/torch_lib/ops/core.py @@ -9,6 +9,7 @@ - All functions should not have the script() decorator. This is because we want to delay the compilation of the function. """ + from __future__ import annotations import math diff --git a/onnxscript/function_libs/torch_lib/ops/fft.py b/onnxscript/function_libs/torch_lib/ops/fft.py index f5f9b3bdb..8b71f7cb4 100644 --- a/onnxscript/function_libs/torch_lib/ops/fft.py +++ b/onnxscript/function_libs/torch_lib/ops/fft.py @@ -9,6 +9,7 @@ - All functions should not have the script() decorator. This is because we want to delay the compilation of the function. """ + from __future__ import annotations from typing import Optional, Sequence diff --git a/onnxscript/function_libs/torch_lib/ops/linalg.py b/onnxscript/function_libs/torch_lib/ops/linalg.py index 48d4f6027..fddf80ac0 100644 --- a/onnxscript/function_libs/torch_lib/ops/linalg.py +++ b/onnxscript/function_libs/torch_lib/ops/linalg.py @@ -9,6 +9,7 @@ - All functions should not have the script() decorator. This is because we want to delay the compilation of the function. """ + from __future__ import annotations from typing import Optional, Sequence diff --git a/onnxscript/function_libs/torch_lib/ops/nested.py b/onnxscript/function_libs/torch_lib/ops/nested.py index 0d1808dce..096ad268f 100644 --- a/onnxscript/function_libs/torch_lib/ops/nested.py +++ b/onnxscript/function_libs/torch_lib/ops/nested.py @@ -9,6 +9,7 @@ - All functions should not have the script() decorator. This is because we want to delay the compilation of the function. """ + from __future__ import annotations from typing import Optional diff --git a/onnxscript/function_libs/torch_lib/ops/prims.py b/onnxscript/function_libs/torch_lib/ops/prims.py index 2b465cacc..3136559b1 100644 --- a/onnxscript/function_libs/torch_lib/ops/prims.py +++ b/onnxscript/function_libs/torch_lib/ops/prims.py @@ -9,6 +9,7 @@ - All functions should not have the script() decorator. This is because we want to delay the compilation of the function. """ + from __future__ import annotations from typing import Optional, Sequence diff --git a/onnxscript/function_libs/torch_lib/ops/sparse.py b/onnxscript/function_libs/torch_lib/ops/sparse.py index a7a4f6074..d3a1fcddb 100644 --- a/onnxscript/function_libs/torch_lib/ops/sparse.py +++ b/onnxscript/function_libs/torch_lib/ops/sparse.py @@ -9,6 +9,7 @@ - All functions should not have the script() decorator. This is because we want to delay the compilation of the function. """ + from __future__ import annotations from onnxscript.onnx_types import TensorType diff --git a/onnxscript/function_libs/torch_lib/ops/special.py b/onnxscript/function_libs/torch_lib/ops/special.py index 5809e874d..6719581f6 100644 --- a/onnxscript/function_libs/torch_lib/ops/special.py +++ b/onnxscript/function_libs/torch_lib/ops/special.py @@ -9,6 +9,7 @@ - All functions should not have the script() decorator. This is because we want to delay the compilation of the function. """ + from __future__ import annotations import math diff --git a/onnxscript/function_libs/torch_lib/ops/vision.py b/onnxscript/function_libs/torch_lib/ops/vision.py index a2f5cb0ee..57e2f8bd0 100644 --- a/onnxscript/function_libs/torch_lib/ops/vision.py +++ b/onnxscript/function_libs/torch_lib/ops/vision.py @@ -4,6 +4,7 @@ # -------------------------------------------------------------------------- # mypy: disable-error-code="misc,arg-type,type-arg,valid-type,assignment,return-value" """torchvision operators.""" + from __future__ import annotations from onnxscript.function_libs.torch_lib.registration import torch_op diff --git a/onnxscript/tests/function_libs/torch_lib/ops_test.py b/onnxscript/tests/function_libs/torch_lib/ops_test.py index 9cae237c8..ac3752eca 100644 --- a/onnxscript/tests/function_libs/torch_lib/ops_test.py +++ b/onnxscript/tests/function_libs/torch_lib/ops_test.py @@ -20,6 +20,7 @@ 2. Set `CREATE_REPRODUCTION_REPORT=1` to create markdown files for reproduction of errors. """ + from __future__ import annotations import os diff --git a/onnxscript/tests/function_libs/torch_lib/ops_test_data.py b/onnxscript/tests/function_libs/torch_lib/ops_test_data.py index 65d5b35f2..ecf4a606d 100644 --- a/onnxscript/tests/function_libs/torch_lib/ops_test_data.py +++ b/onnxscript/tests/function_libs/torch_lib/ops_test_data.py @@ -32,6 +32,7 @@ op, use `ops_test_common.duplicate_opinfo` to create new OpInfo with new names and map each to one overload. """ + from __future__ import annotations import copy diff --git a/onnxscript/tests/onnx_types_test.py b/onnxscript/tests/onnx_types_test.py index 3293fa0fa..8e9a96eb5 100644 --- a/onnxscript/tests/onnx_types_test.py +++ b/onnxscript/tests/onnx_types_test.py @@ -6,6 +6,7 @@ # mypy: disable-error-code=misc """Unit tests for the onnx_types module.""" + from __future__ import annotations import unittest diff --git a/onnxscript/values.py b/onnxscript/values.py index ba562b38b..4b3494d3a 100644 --- a/onnxscript/values.py +++ b/onnxscript/values.py @@ -250,19 +250,15 @@ class OpLike(Protocol): """A protocol for objects that have an ONNX OpSchema.""" @property - def name(self) -> str: - ... + def name(self) -> str: ... @property - def opset(self) -> Opset: - ... + def opset(self) -> Opset: ... @property - def op_schema(self) -> Optional[onnx.defs.OpSchema]: - ... + def op_schema(self) -> Optional[onnx.defs.OpSchema]: ... - def param_schemas(self) -> Optional[tuple[ParamSchema, ...]]: - ... + def param_schemas(self) -> Optional[tuple[ParamSchema, ...]]: ... class Op(OpLike): diff --git a/requirements/lintrunner/requirements.txt b/requirements/lintrunner/requirements.txt index 4be10ef3c..e69b81440 100644 --- a/requirements/lintrunner/requirements.txt +++ b/requirements/lintrunner/requirements.txt @@ -1,7 +1,7 @@ # This file is auto updated by dependabot lintrunner-adapters>=0.8.0 # RUFF, RUFF-FIX -ruff==0.2.1 +ruff==0.3.0 # MYPY mypy==1.8.0 types-PyYAML==6.0.12.11 diff --git a/setup.py b/setup.py index 1e1f2e057..6481278ea 100644 --- a/setup.py +++ b/setup.py @@ -27,9 +27,9 @@ ["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=False ) if commit_hash_cmd.returncode == 0: - project_urls[ - "Commit" - ] = f"https://github.com/microsoft/onnxscript/tree/{commit_hash_cmd.stdout.decode('utf-8').strip()}" + project_urls["Commit"] = ( + f"https://github.com/microsoft/onnxscript/tree/{commit_hash_cmd.stdout.decode('utf-8').strip()}" + ) # NOTE: Do not include other metadata in setup.py. Put it in pyproject.toml. setuptools.setup(version=version, project_urls=project_urls, url="https://onnxscript.ai/")