-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat: Ruff Configuration Settings #2215
feat: Ruff Configuration Settings #2215
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we should disable the errors in the ConsoleInput, that's not a good time. It's always giving errors for variables that do exist.
Also we need to fix up the unit tests, I think a transformIgnore in jest needed.
@@ -108,13 +113,13 @@ export class LocalWorkspaceStorage implements WorkspaceStorage { | |||
serverConfigValues, | |||
'showExtraGroupColumn' | |||
), | |||
defaultNotebookSettings: | |||
notebookSettings: | |||
serverConfigValues?.get('isMinimapEnabled') !== undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should have server definitions for the other defaults here as well, can create a ticket to document on the server in the dh-default.prop file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should we handle these? Should I flatten the config for notebooks instead in redux? Right now the code that merges w/ server notebookSettings
would actually only add isMinimapEnabled
and not use any of the other defaults. It doesn't deep merge. Could also change to a deep merge
): DebouncedFunc<(...args: TArgs) => TResult> { | ||
const { leading = false, trailing = true, maxWait } = options; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kind of dumb the defaults are needed here, but yes this is needed.
The docs show it should default a value: https://lodash.com/docs/4.17.15#debounce
But the code doesn't actually check if the value is undefined
before using it: https://github.com/lodash/lodash/blob/6a2cc1dfcf7634fea70d1bc5bd22db453df67b42/src/debounce.ts#L88
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep I figured that out through trial and error, but good to know the code confirmed my suspicions that they were coercing falsey value to false. I should probably add tests for this
I also made this not require a stable object into the hook because to me it's better to hide that in the hook implementation since it's simple. That way the calls are more clear with useDebouncedCallback(fn, timeout, { leading: true })
@@ -146,7 +146,7 @@ button:focus { | |||
} | |||
|
|||
span.btn-disabled-wrapper { | |||
display: contents; | |||
display: inline-block; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You sure this is correct? This is the reverting a previous change you made: 96641fb#diff-5297df85e91eab4d0994f382be57fbae24870c628aa9472306cc3073a0310b0a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like from my past conversation w/ Don this was an attempted fix for disabled buttons w/ tooltips in flex containers. But now this causes a shift/slight shrink on the button in the modal context.
I'll try to see if there's a better fix. Looks like it was a fix for the left/right arrows when you have a lot of dashboards open so that probably is aligned incorrectly now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm keeping this because it seems display: contents
is making the tooltips not show up at all when disabled. There's been some changes to the button component around themeing which seems to have fixed the disabled icon buttons with tooltips when I leave this as inline-block
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[isOpen] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might need a comment why onOpened
is not being included as a dep here. That seems like a bug?
Side note, Modal
should likely be deprecated in favour of Dialog and DialogTrigger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returned to its original version.
Currently staying with Modal because Dialog uses a different background color which makes monaco's background look jarring to me
// Register the ruff schema so users get validation and completion | ||
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({ | ||
validate: true, | ||
enableSchemaRequest: true, | ||
schemas: [ | ||
{ | ||
uri: 'json://ruff-schema', | ||
fileMatch: [model.uri.toString()], | ||
schema: ruffSchema, | ||
}, | ||
], | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a sloppy way to do this - it's setting it on a static context whenever we open the editor, and replacing previous settings with one that just matches the new model.
Could you use monaco.editor.createModel
to create a model ahead of time and re-use that? And just register the schema once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could augment Editor
to accept a URI or even a full model. If you try to create a model w/ an existing Uri you get an error, but you can also get an existing model by Uri. In this case we could have a consistent model uri and just file match the 1 uri for ruff settings
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/python-formatter #2215 +/- ##
============================================================
+ Coverage 46.04% 46.54% +0.49%
============================================================
Files 695 698 +3
Lines 39267 38865 -402
Branches 9875 9718 -157
============================================================
+ Hits 18082 18088 +6
+ Misses 21085 20766 -319
+ Partials 100 11 -89
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
packages/redux/src/store.ts
Outdated
isMinimapEnabled?: boolean; | ||
formatOnSave?: boolean; | ||
ruffSettings?: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nest this under python
namespace, e.g.
notebookSettings: {
...
python: {
linter: {
isEnabled?: boolean;
config: ...,
};
}
}
Defined on the server, namespaced under web.user
or web.client
(which they aren't right now), and we should automatically load all of those set values (web.client.*
) and transfer them (rather than having to explicitly client.configuration.list
):
web.client.notebookSettings.isMinimapEnabled
web.client.notebookSettings.python.linter.isEnabled
Then do a deep merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added these under web.user
and tested locally by adding web.user.notebookSettings.python.linter.isEnabled
to my dh-defaults.prop#client.configuration.list
. Then set the prop in my local prop file and tested in incognito that the server setting default was applied
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
3144edb
into
deephaven:feature/python-formatter
Fixes #1255
I need to test this doesn't crash if using groovy. Not sure if the ruff version is available without initializing ruff first or what happens if it's unavailable.
Something we should add maybe as part of this PR or a final follow-up to this feature branch is disabling certain/all linting/formatting for the console. One way we might do this is by registering the console w/ a specific URI or URI scheme so we can check it when checking if we should lint. Or include it as a prop to the
MonacoProviders
component. This would require some changes to the current setup of setting/using the config onMonacoProviders
static members/methods(This might not actually be breaking, it's more just notes for implementing in DHE)
BREAKING CHANGE:
The app should call
MonacoUtils.init
with agetWorker
function that uses the JSON worker in addition to the general fallback worker when adding support for configuring ruff.