Replies: 2 comments 8 replies
-
Oh, hey, @BurntSushi, since you're active in this repo too (❤️), would you be open to allowing alternate (non-path-slash) separators in |
Beta Was this translation helpful? Give feedback.
3 replies
-
I haven't thought much about the problem but my thoughts around your proposal (and some related thoughts)
|
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Terminology: "call path":
ruff/crates/ruff_python_ast/src/call_path.rs
Lines 5 to 6 in e9acb99
glob
andglobset
crates; it should maybe only use one (likelyglobset
, since it's more capable and has tricks up its sleeve to optimize matching – though at a quick glance, it doesn't have an ergonomic API for matching only one glob – but then again, maybe using a globset in all cases would be fine).isort
uses one, and Support glob patterns in pep8_naming ignore-names #5024 implemented another, and I was just about to implement a third one in WIP/RFC: Wildcards forbanned_api
#8274 before taking a step back, a deep breath, etc.In a perfect-er world, I think we'd have a nice generic
CallPathMatchMap<T>
type that would allow a Ruff developer to map from patterns (supplied by an user) to some other data of typeT
; forisort
, the other data would be the import category, forpep8-naming
ignore-names it would probably just betrue
, forbanned_api
it would be themsg
(and maybe other future data). (For additional cleverness & performance, that type could fall back to being just aFxHashMap
when it knows no pattern needs wildcard matching; on the other hand,One issue with using either
glob
orglobset
for matching call paths is that the "deep star" (**
) element won't be supported as one might expect (IOW, I'd expectfoo.*.bar
to matchfoo.x.bar
,foo.y.bar
but notfoo.x.y.bar
) since*
is supposed to stop at path delimiters (/
), not at dots. I can think of two solutions for this: either add support for alternate element delimiters in the upstreamglob
orglobset
crates, or represent call paths internally with slash-delimited paths. (This could of course be hidden behind that nice facade; no one would need to know. 🤫)Beta Was this translation helpful? Give feedback.
All reactions