News for hackers. Stuff that matters.
Re:Pyrefly by koakuma-chan on Tuesday April 29, 2025 @10:58AM (#43833578)
> pyrefly check --suppress-errors

> INFO 5,240 errors shown, 65,932 errors ignored

Not a single Python type checker had ever worked for me so far.

Re:Pyrefly by kstrauser on Tuesday April 29, 2025 @11:01AM (#43833617)
I don't see the link between that output and your conclusion. Are those results wrong?
Re:Pyrefly by koakuma-chan on Tuesday April 29, 2025 @11:04AM (#43833671)
> Are those results wrong?

I don't know. Some packages just don't work with type checkers, e.g. Django.

Re:Pyrefly by masklinn on Tuesday April 29, 2025 @11:17AM (#43833839)
Django has a community stubs project, are you using it?
Re:Pyrefly by etimberg on Tuesday April 29, 2025 @02:55PM (#43836584)
the stubs can only do so much. There's so much magic and inferred properties that a type checker will never be able to fill in alone
Re:Pyrefly by aitchnyu on Wednesday April 30, 2025 @02:03AM (#43841731)
Does django-stubs work with other type checkers than Pyright?
Re:Pyrefly by masklinn on Sunday May 04, 2025 @03:32AM (#43885182)
Stubs are a standard python feature (PEP 561) so I'd expect them to work with any type checker which supports stubs, which should be all of them (as much of the ecosystem is typed via stubs).
Re:Pyrefly by johnisgood on Tuesday April 29, 2025 @11:41AM (#43834159)
Is it not that he used the "--suppress-errors" flag yet it did not ignore the errors?
Re:Pyrefly by kstrauser on Tuesday April 29, 2025 @12:27PM (#43834775)
It's hard to tell. Other similar options in other commands can mean things like "exit with status 0 even if errors are detected". Without installing pyrefly, I'm not sure what that flag's supposed to do. It's not documented on their site.
Re:Pyrefly by koakuma-chan on Tuesday April 29, 2025 @12:30PM (#43834811)
It adds a comment to suppress the error above each line in your codebase that causes an error, but it reports the errors before doing that, so you can only see the result after you re-run `pyrefly check`.
Re:Pyrefly by kstrauser on Tuesday April 29, 2025 @01:12PM (#43835362)
Oh! That's nifty. It leaves you with a baseline so you can stop making new mistakes, and gives you something to grep for when you want to fix existing ones.
Re:Pyrefly by ipsum2 on Tuesday April 29, 2025 @11:04AM (#43833655)
It's literally working? What did you expect?
Re:Pyrefly by koakuma-chan on Tuesday April 29, 2025 @11:06AM (#43833694)
Maybe it's working but it's not useful.
Re:Pyrefly by masklinn on Tuesday April 29, 2025 @11:18AM (#43833854)
What would you expect "useful" to be if your codebase is basically incompatible with type checking?
Re:Pyrefly by koakuma-chan on Tuesday April 29, 2025 @11:39AM (#43834123)
I expected that I would be able to run the check command and it would just work. Upon reading the docs, this tool recommends incremental adoption, and after using `--suppress-errors`, `# pyrefly: ignore` is all over my codebase.
Re:Pyrefly by krick on Tuesday April 29, 2025 @11:55AM (#43834371)
I know I shouldn't get into this thread, but I'm extremely curious: what did you expect should have happened? I mean, literally, what do you mean by "just work", what work did you expect a type checker to perform if not to show you errors?
Re:Pyrefly by koakuma-chan on Tuesday April 29, 2025 @12:11PM (#43834580)
I expected a reasonable amount of reasonable errors, not 60k+ errors most of which are import-error, even though the code runs fine.
Re:Pyrefly by fastasucan on Tuesday April 29, 2025 @04:12PM (#43837502)
Its the fault of the tool that the codebase had lots of errors?
Re:Pyrefly by koakuma-chan on Tuesday April 29, 2025 @04:28PM (#43837669)
I would say it's the fault of the ecosystem. Hopefully it will get better as libraries adopt type hints.
Re:Pyrefly by nerdponx on Tuesday April 29, 2025 @11:51AM (#43834307)
That's incremental adoption for adding type hints, not for adopting this particular tool in an already-type-hinted codebase.
Re:Pyrefly by Yossarrian22 on Tuesday April 29, 2025 @11:50AM (#43834302)
…how else would it work?
Re:Pyrefly by fastasucan on Tuesday April 29, 2025 @04:11PM (#43837487)
What does "just work" mean? You are comically obtuse.
Re:Pyrefly by ForHackernews on Tuesday April 29, 2025 @11:05AM (#43833676)
Fix your types.
Re:Pyrefly by IshKebab on Tuesday April 29, 2025 @11:44AM (#43834213)
Do you... have type annotations? I think you might be missing the point.
Re:Pyrefly by jon-wood on Tuesday April 29, 2025 @11:58AM (#43834406)
I think the point here is that for something like Python the default behaviour should be an assumed return type of `Any` rather than throwing an error. Maybe that is the case and the GP had configured it otherwise.
Re:Pyrefly by IshKebab on Tuesday April 29, 2025 @02:39PM (#43836396)
No it shouldn't because then you can easily miss places where you should have added a type annotation, and also your lazy colleagues won't bother adding them at all.
Re:Pyrefly by darthrupert on Wednesday April 30, 2025 @01:39AM (#43841606)
The worst of both worlds is colleagues who insert type annotations but they're wrong. And there's no CI pipe to verify the types before check-in.

Working with these things makes me often think that people who want to write high quality software should just use a better language. But, well, real world is real.

Re:Pyrefly by koakuma-chan on Wednesday April 30, 2025 @12:48PM (#43847830)
> just use a better language

This

Re:Pyrefly by IshKebab on Thursday May 01, 2025 @08:26AM (#43856775)
Yeah unfortunately Python is crazy popular so a lot of the time you don't get a choice.

If fairness if you set up uv and Ruff and Pyright it's kind of ok. Still have to deal with the general noobness of the ecosystem and the horrific performance, but I've seen worse.

Re:Pyrefly by team_pyrefly on Tuesday April 29, 2025 @02:39PM (#43836403)
Thanks for giving this a try! We go over how to use the upgrade tooling (`--suppress-errors`) in the guide here: https://pyrefly.org/en/docs/installation/. This is intended to make upgrading from different versions of type checkers easier. It’s something we use internally and wanted to share with the community along with the checker itself.

We also allow you the ability to suppress whole classes of errors if you want to ignore specific error types and avoid inline ignores: https://pyrefly.org/en/docs/configuration/ A word of caution: this will ignore future errors of this type as well.

First, make sure your project is properly configured and then follow the instructions. `--suppress-errors` will add ignores inline allowing the project to check cleanly. We have thought about a feature that allows you to keep suppressions in a separate file, but we have not put it on the roadmap yet. If this is something important for your workflow, we would like to learn more - please add a feature request on GitHub.

Re:Pyrefly by darthrupert on Wednesday April 30, 2025 @01:37AM (#43841596)
Don't blame the tool for your shoddy work. Either accept your mediocre quality or do something to fix it.