pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Support checking python file without extension

Open bulletmark opened this issue 1 month ago • 1 comments

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

bulletmark avatar Dec 01 '25 12:12 bulletmark

Seems reasonable, tho I think this should only happen when you explicitly pass a file name without an extension

yangdanny97 avatar Dec 01 '25 16:12 yangdanny97

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 avatar Dec 03 '25 17:12 connernilsen

@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.

bulletmark avatar Dec 03 '25 21:12 bulletmark

@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:

  1. Auto-detect explicit files by checking for glob chars (*, ?, [)
  2. Skip extension check for explicit files (but still validate they exist)
  3. Keep current behavior

This addresses @connernilsen's performance concern since discovered files still require extensions - no risk of scanning entire directories accidentally.

AryanBagade avatar Dec 05 '25 18:12 AryanBagade

@yangdanny97 could you please assign me this issue

AryanBagade avatar Dec 12 '25 18:12 AryanBagade