Repository navigation
Rule documentation link does not work with lower case code #15016
Description
Activity
- addeddocumentationImprovements or additions to public-facing documentationImprovements or additions to public-facing documentation
on Dec 16, 2024 - changed the title
[-]documentation mirror does not work with lower case letters[/-][+]Rule documentation link does not work with lower case code[/+]on Dec 17, 2024 Yeah, I noticed this last week and I was wondering if this should be allowed because the rule selection wouldn't allow lowercase either (
select = ["f401"]doesn't work). The same argument can be applied to rule names as well as it only works with lower case names so https://docs.astral.sh/ruff/rules/Unused-Import doesn't work.What would be the argument not to allow it?
I guess formally you're right that it's an "invalid" rule code, but I don't think there's any level of confusion of what is intended when a user inputs a rule code with a lower case letter.
I find it convenient to type the rule code without worrying about the capitalization, and have now a few times been surprised as to why it doesnt always work (until I discovered that it'll only work if I've been on that page before).I think it's fine to add the lowercase variant. The following would need to be updated to generate the redirects from lowercase rule codes as well:
ruff/scripts/generate_mkdocs.py
Lines 257 to 266 in 7ddf59b
config["plugins"].append( { "redirects": { "redirect_maps": { f"rules/{rule['code']}.md": f"rules/{rule['name']}.md" for rule in rules }, }, }, ) - added a commit that references this issue
on Jan 18, 2025
When trying to load a specific rule's documentation page using a the lower case letter for that rule (e.g. https://docs.astral.sh/ruff/rules/f401), I get a
404 - Not Found.After loading the page once using an uppercase letter instead (which does work), if I then try it again with the lowercase, my browser (Firefox) automatically corrects the lowercase to the uppercase and the site does load.
It might be nice to make the mirror work immediately in a case insensitive manner.