From f1c14ef435b8723ce875ad4610fd06f7c6e289d3 Mon Sep 17 00:00:00 2001 From: Maxime Armstrong <46797220+maximearmstrong@users.noreply.github.com> Date: Thu, 9 May 2024 16:02:29 -0400 Subject: [PATCH] Ignore Pyright error in create_dagster_package.py (#21688) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary & Motivation This PR adds a `#type: ignore` to 2 lines in `scripts/create_dagster_package.py` so that Pyright stops yelling. No changes were made to the script in one year, so this is most likely coming from a new Pyright version. Also, disables the Pyright rule `reportUnnecessaryTypeIgnoreComment` for the same reasons as in #21525 Local error: ``` python scripts/run-pyright.py --all Creating temporary pyright config file at pyrightconfig-alt-1.json Running pyright for environment `alt-1`... pyright --project=pyrightconfig-alt-1.json --outputjson --level=warning --warnings Creating temporary pyright config file at pyrightconfig-master.json Running pyright for environment `master`... pyright --project=pyrightconfig-master.json --outputjson --level=warning --warnings /Users/maximearmstrong/Documents/Repositories/dagster-io/dagster/scripts/create_dagster_package.py: 102:56: Argument of type "TextIOWrapper" cannot be assigned to parameter "fp" of type "str | IO[bytes]" in function "dump"   Type "TextIOWrapper" cannot be assigned to type "str | IO[bytes]"     "TextIOWrapper" is incompatible with "str"     "TextIOWrapper" is incompatible with "IO[bytes]"       Type parameter "AnyStr@IO" is invariant, but "str" is not the same as "bytes" (reportArgumentType) 127:15: Argument of type "TextIOWrapper" cannot be assigned to parameter "fp" of type "str | IO[bytes]" in function "dump"   Type "TextIOWrapper" cannot be assigned to type "str | IO[bytes]"     "TextIOWrapper" is incompatible with "str"     "TextIOWrapper" is incompatible with "IO[bytes]"       Type parameter "AnyStr@IO" is invariant, but "str" is not the same as "bytes" (reportArgumentType) pyright 1.1.356 Finished in 49.03 seconds Analyzed 3440 files Found 2 errors Found 0 warnings make: *** [pyright] Error 1 ``` [BK error](https://buildkite.com/dagster/dagster-dagster/builds/82305#018f4f19-b9a3-4d04-9525-40678bb5ede0) ## How I Tested These Changes ``` make rebuild_pyright_pins make pyright ``` BK --- scripts/create_dagster_package.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/create_dagster_package.py b/scripts/create_dagster_package.py index 58d5ed63c34d5..dc4a494b26635 100644 --- a/scripts/create_dagster_package.py +++ b/scripts/create_dagster_package.py @@ -1,4 +1,6 @@ +# pyright: reportUnnecessaryTypeIgnoreComment=false # ruff: noqa: T201 + import os import click @@ -99,7 +101,7 @@ def _make_dagster_package(package_name: str): print(f"Writing {to_create}") template = jinja_env.get_template(f"{to_create}.tmpl") with open(variables["path"], "w") as f: - template.stream(**variables["kwargs"]).dump(f) + template.stream(**variables["kwargs"]).dump(f) # type: ignore if variables["has_todos"]: has_todos.append(variables["path"]) @@ -124,7 +126,7 @@ def _make_dagster_package(package_name: str): hyphen_name=package_name, underscore_name=package_name_underscore, formal_name=formal_name, - ).dump(f) + ).dump(f) # type: ignore has_todos.append(docs_path)