-
-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mark 'file-only-linters' using ${real_file}
in cmd
#1022
Mark 'file-only-linters' using ${real_file}
in cmd
#1022
Conversation
I think it’s kinda ugly to switch the implementation on magic words inside a string. I think I’d prefer a separate setting. |
Think that the user can set 'cmd' via the settings. This is rather expressive. For the implementation you could easily switch to a getter like My proposal in #954 (comment) is based on making 'cmd' 'expressive'. I don't have other ideas atm. |
Ok, that’s not a bad idea. I guess I don’t have any strong opinions or brilliant ideas on this one. |
This pattern does not support the following situations:
The former could be detected by the additional presence of a temp_file argument, but I liked the idea of exposing the three lint modes and a mode-specific cmd override more. Example config (pseudo): lint_mode = TEMPORARY_FILE | REAL_FILE # no STDIN, which would override TEMPORARY_FILE
cmd = 'mypy --shadow-file ${real_file} ${temp_file} ${real_file}'`
cmd_real = 'mypy ${file}' # expands to ${real_file} in REAL_FILE mode; chose to override this mode since the other two are exclusive and this only requires the addition of one "alias" |
You should use ${file} here
likewise for 'mypy' |
Okay, nvm. I was confusing some lines a but during the diff review. Using I'm not too fond of the idea as I liked being able to supply the lint modes explicitly instead of this (slightly confusing) magic, but at least it works, unlike I assumed initially. I'd like to see what @braver has to say about my proposal, since he wasn't a fan of the magic either. |
As an update, there are probably better ways to provide different command lines for different lint modes than a separate "cmd_real" attribute/setting. I could imagine a dict, for example: cmd = {
TEMPORARY_FILE: 'mypy --shadow-file ${real_file} ${temp_file} ${real_file}',
REAL_FILE: 'mypy ${file}',
} (Note that I edited my earlier comment a couple times.) |
There is no expressed user story in the original issue why you would want to declare different 'cmd's (statically) upfront. Note also that there is no magic here. We don't guess anything, no opinions, no heuristics. (The notion of magic at least involves that something is automatic.) Some explanations. Currently, we (already) have a setting that actually branches all possible ways. It is called unfortunately
Note (@braver) that the 'magic' Now, if we have two settings ( So, if you're in a situation like this, it is probably better to make the branching based on one setting (here: Generally, it is important to keep in mind that (If you define 'cmd' as a dict, should every plugin provide three different commands to be a nice citizen? How do we actually switch between them?) |
I know, it's terrible. With a getter, as you suggest, it would be a lot better.
A very good point, I didn't think that true.
Isn't having multiple cmd's a different discussion altogether? I think I kinda get why you'd want that, but it's not a big thing IMO. Perhaps focus on replacing the |
That's true. The requirement was just to get rid of the
It's simpler to specify only a single value instead of having the "redundancy" of a separate setting and specific variables in the cmd, but it irks me that
I have a suggestion about that (see below). Time for summarizations. Here's your current proposal: Current proposal
My proposal
Advantages
Disadvantages
Disadvantages for both
|
This feels like a mixing of user story and implementation details.
That's confusing, they're not functionally equivalent. From the point of view of SL TEMP and STDIN share that they can operate on unnamed and dirty buffers. From the point of the linters REAL AND TEMP share that they both operate on real files.
'lint_mode' would be a user setting, so no BIT_FLAGS pure strings.
${temp_file} would not be needed anymore bc ${file} changes its values based on the mode.
We want the option to have Generally, the same setting with various meanings is 'implicit behavior change[s] based on the usage of a different variable' This is confusing. Advantages
I don't think that this is true. You cannot set
You get a part of #244 for free for both proposals. But lint_mode is otherwise completely unrelated. It also has 'manual'.
This is the meat here. This is interesting, but probably nobody wants it. E.g. there is no real user interest to lint the real file and then use the buffer contents via STDIN in quick alternations. Why would you want this with
This is about 'consistency'. Trying to reduce invalid states of a program. |
I realized the wording was poor, but was hoping you'd understand anyway. Yes, they are not functionally equivalent, but they have the same results and you don't need two things producing the same thing at the same time.
Good thinking. I'll take that as an advantage?
Bummer, I forgot about that. It'd need to be escaped (in JSON even, so >>> sublime.expand_variables("$undefined", {})
''
I did say "for most situations", though. Obviously that's just an estimate, but no linter I use requires
Yes, but with your proposal they'd need to understand the implications of variable usages in
True, users don't care about this.
This can actually be beneficial, too. If a user overrides |
May I remind you that we have currently for that feature/enhancement. You cannot justify such a huge change for a 1% problem. You cannot say that making Let's say I have to think about this more. |
If
Yes, but you wouldn't need to modify I put the "probably more code" in the disadvantages section for a reason, because I most certainly do believe it will increase code complexity, but don't think it would actually increase UX complexity. I may just be a single person, but the mere presence of a certain substring inside a setting having a side effect on how that string is used (i.e. changing the lint mode) started ringing alarm bells inside my head. It's not how I would design my software, although I may struggle to articulate for reasons. Similar to saying what is considered "pythonic" and what is not. I guess I prefer having things purpose-built. Either way, I believe it is my responsibility as a considerate user and developer myself to share ideas that I think might result in improvements. It is not my decision whether to implement them or the way of that implementation, which is why I provided the comparsion earlier and try to make my thought process as easy to follow as I can. We wouldn't want this to be a breaking change, so take your time. It might also help to ask someone else about their opinion, but they'd have to be involved with the current process and understand the two seperate proposals, which takes at least some time. |
Now I get this example
But this is not true bc e.g. Now, I summarize the usage again:
|
Oops, that was posted too early.
|
Explains #954 (comment)
Maybe fixes #954
Here we use ${real_file} in
cmd
as a marker to mark 'file-only-linters', we use ${tmp_file} to mark linters that operate on temporary files, everything else (except the compatibility branching) uses STDIN.