Closed dshahbaz closed 1 week ago
I think there's two immediate things we could do:
--extensions
flag to override which extensions are parsed at runtime.Happy to review a PR.
I think option #1 is best.
/bounty $10
/attempt #485
with your implementation plan/claim #485
in the PR body to claim the bountyThank you for contributing to getgrit/gritql!
Add a bounty • Share on socials
Attempt | Started (GMT+0) | Solution |
---|---|---|
🟢 @mobley-trent | Oct 24, 2024, 11:14:16 AM | WIP |
🟢 @Alex-ley-scrub | Oct 24, 2024, 10:46:04 PM | #562 |
/attempt #485
Algora profile | Completed bounties | Tech | Active attempts | Options |
---|---|---|---|---|
@mobley-trent | 10 bounties from 5 projects | Python, Rust, Jupyter Notebook |
Cancel attempt |
/attempt #485
@dshahbaz what is the suffix of the file out of curiosity if you don't mind sharing?
It's not "pyi" by any chance is it? Or another (semi) valid/standard python extension? .pyi - Stub file (PEP 484)
I only ask because if it is .pyi I believe they are a true subset of .py files (they're just interface files with function signatues and type hints but no implementations, instead just have ...
in the function bodies etc.) and should be able to be parsed just like a normal .py file.
@morgante should we consider to add "pyi" here (I've done that in this commit 63f113c in case the answer is yes, otherwise can revert):
This is my minimal reproducible example (added as a test case in this commit 9abf798):
These both fail for me using the released version of grit (with or without --force
):
echo 'class MyClass(object): ...' > dummy.nopy
grit apply '`object` => ``' dummy.nopy --lang=python --force
# out: dummy.nopy: ERROR (code: 410) - Skipped dummy.nopy since it is not a python file
# out: Processed 2 files and found 0 matches
and
echo 'class MyClass(object): ...' > dummy.pyi
grit apply '`object` => ``' dummy.pyi --lang=python --force
# out: dummy.pyi: ERROR (code: 410) - Skipped dummy.pyi since it is not a python file
# out: Processed 2 files and found 0 matches
(as an aside the count of processed files seems to be doubled for the failed ones, which I also fixed in this commit ff3fafc)
see my PR attempt coming shortly
Algora profile | Completed bounties | Tech | Active attempts | Options |
---|---|---|---|---|
@Alex-ley-scrub | 2 grit bounties | Rust |
Cancel attempt |
Adding .pyi
seems reasonable, as well as fixing the overall problem.
/assign @Alex-ley-scrub
💡 @Alex-ley-scrub submitted a pull request that claims the bounty. You can visit your bounty board to reward.
🎉🎈 @Alex-ley-scrub has been awarded $10! 🎈🎊
Thank you! I haven't tried this yet.
In my use case I was attempting to use bazel BUILD
files, which approximately python, at least in terms of syntax.
I have files that should be treated as python, but do not end in
.py
. I can't convincegrit
to respect the files and treat them as python with any option or config value that I've found. Instead, grit fails with:My workaround is hardlinking to .py, but it would be ideal to force grit to ignore the suffix, or to register alternative patterns as a file type using
grit.yaml
.