Support checking python file without extension
Describe the Bug
pyrefly will not check a python file/script unless it has a python extension, e.g:
$ pyrefly check myscript
No Python files matched pattern `/home/mark/myprog/myscript`
$ pyrefly --version
pyrefly 0.43.1
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
No response
Seems reasonable, tho I think this should only happen when you explicitly pass a file name without an extension
I originally chose to not support non-python suffixed files because my assumption was they wouldn't often be type checked as standalone files, especially since they can't be imported. I typically view them as quick scripts rather than something we expect to maintain. This is not a very strong opinion though, so definitely open to making changes here.
I'm not sure I agree with analyzing the input format of files though. If a single file is passed, it would be easy to tell and perform different behavior, but getting that to work with configs and the IDE will be a lot more complicated.
Maybe this should be another flag? One concern I have is that you have to be really specific about your project includes on large projects to avoid slowing down the type checker by a ton, since this is something we currently specify on includes and cannot specify for excludes.
@connernilsen you mention "single file" but please note I may want to specify pyrefly check myscript1 myscript2 etc. I.e. any files the user specifies on the command line should be checked. I may even have a dir of scripts so I may check them all with pyrefly *.
As examples, I check my shell scripts with shellcheck my-shell-script and my python scripts/programs with ruff check my-python-script, mypy my-python-script, pyright my-python-script etc. All of them take 1 or more file arguments and don't require any filename extension or other naming convention. So I expect pyrefly my-python-script should also be possible. That is all this issue is about.
@yangdanny97
Files without .py extension get blocked at globs.rs even when explicitly passed
we can do something like only allow extension-less files when explicitly passed on CLI:
- Auto-detect explicit files by checking for glob chars (
*,?,[) - Skip extension check for explicit files (but still validate they exist)
- Keep current behavior
This addresses @connernilsen's performance concern since discovered files still require extensions - no risk of scanning entire directories accidentally.
@yangdanny97 could you please assign me this issue