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

Update ci #202

Merged
merged 10 commits into from
Feb 19, 2024
Merged

Update ci #202

merged 10 commits into from
Feb 19, 2024

Conversation

jakkdl
Copy link
Member

@jakkdl jakkdl commented Feb 15, 2024

async def foo(): ...

as an empty function, since it was matching against the indented body. This is now the black style, which is why I found it. So fixed that, and updated test file to have both.
There's only a few more instances of IndentedBlock in the project, and none seem problematic, but it's possible this could be a problem in other places.

I can split this across multiple PRs, but idk if it's warranted. Now that we moved and can set up pre-commit it should be more incremental going forward.

@jakkdl jakkdl requested a review from Zac-HD February 15, 2024 15:27
@jakkdl
Copy link
Member Author

jakkdl commented Feb 15, 2024

@thejcannon @aneeshusa

Copy link

@thejcannon thejcannon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly little things

error_codes: dict[str, str] # pyright: ignore[reportUninitializedInstanceVariable]
error_codes: ClassVar[
dict[str, str]
] # pyright: ignore[reportUninitializedInstanceVariable]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that ignore still firing? I assume so :/

Also, why isn't line 163 changed (or other cases that look exactly like this)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not! And turns out reportUnnecessaryTypeIgnoreComment doesn't default to true with strict = true, so time to turn that on.
I did change this one hoping it would flow through and silence RUF012 ("Mutable class attribute should be annotated with typing.ClassVar") to the classes inheriting from it - but when that didn't happen I silenced the error rather than change it in the 25 other places. But maybe I'll bother doing the big search&replace

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh hm, the reason it wasn't enabled is because there's no separate setting for pyright: ignore vs type: ignore (and unlikely to be added), and mypy doesn't have mypy: ignore

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could perhaps enable mypy's type: ignore, but that'd involve adding a bunch of deps to its pre-commit env and/or go through a bunch of them and replace with pyright: ignore - and I don't think that's worth bothering with currently.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we annotate as Mapping[str, str] so that it's logically immutable maybe our typecheckers will be happier?

Comment on lines +32 to +34
T_EITHER = TypeVar(
"T_EITHER", bound=Union[Flake8TrioVisitor, Flake8TrioVisitor_cst]
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't previously specify python_version in pyproject.toml for mypy, and now that I did it didn't like the old version which wouldn't work at runtime - and mypy doesn't seem to detect that we're inside an if TYPE_CHECKING block.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although I never remember which tools want python_version to be set to max-version-you-support vs min-version-you-support, so maybe should set it to 3.12 instead of 3.9

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mypy wants you to run separate runs of all of them in parallel x)
python/mypy#12286

def bar(*args) -> Any: ...


# mypy now treats `if ...` as `if True`, so we have another arbitrary function instead

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean...

>>> bool(...)
True

😂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was tempted for a second to report it to mypy until I realized that it's probably better this way in case it sneaks into production code...

@@ -39,10 +38,10 @@ async def foo_yield(): # TRIO911: 0, "exit", Statement("yield", lineno+2)


async def foo_if():
if ...:
if foo():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since foo is async, should we if bar() in these places?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, I'd expect that to trigger mypy's unused-coroutine but I guess the return value is technically used.
Reported it at python/mypy#16921 (comment)

For the test file it of course doesn't really matter, unless mypy starts treating if foo(): as if True: 😁, but yeah no reason not to.

Comment on lines +123 to +125
async for ( # error: 8, Statement("try/finally", lineno-3)
i
) in trio.bypasslinters:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What spurred this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New version of Black now considers the line too long (90>88 after all) and splits it up, after which I move the comment back to line 123.
Not super pretty, maybe worth reporting upstream.

tests/eval_files/trio91x_autofix.py Outdated Show resolved Hide resolved
Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks John!

tox.ini Outdated Show resolved Hide resolved
…I missed, add py313 support now that hypothesmith is updated
@Zac-HD Zac-HD merged commit 953a945 into python-trio:main Feb 19, 2024
8 checks passed
@jakkdl jakkdl deleted the update_ci branch February 19, 2024 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TCH002 false alarm when importing submodule with import..as
3 participants