-
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
fix: Change ruff errors to warnings and fix config saving #2246
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,15 +51,24 @@ export function EditorSectionContent(): JSX.Element { | |
(newValue: Record<string, unknown>) => { | ||
dispatch( | ||
updateNotebookSettings({ | ||
python: { linter: { ...ruffSettings, config: newValue } }, | ||
python: { | ||
linter: { | ||
...ruffSettings, | ||
config: | ||
JSON.stringify(newValue) === | ||
JSON.stringify(RUFF_DEFAULT_SETTINGS) | ||
? undefined | ||
: newValue, | ||
}, | ||
}, | ||
}) | ||
); | ||
MonacoProviders.setRuffSettings(newValue); | ||
}, | ||
[dispatch, ruffSettings] | ||
); | ||
|
||
const [val, setVal] = useState(JSON.stringify(ruffConfig, null, 2)); | ||
const val = JSON.stringify(ruffConfig, null, 2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we memoize this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it matters. The object isn't that big and there's still some overhead to do the string comparison for memoization. Also the component shouldn't re-render often. |
||
|
||
const [isRuffSettingsOpen, setIsRuffSettingsOpen] = useState(false); | ||
|
||
|
@@ -70,7 +79,6 @@ export function EditorSectionContent(): JSX.Element { | |
const handleRuffSettingsSave = useCallback( | ||
(v: Record<string, unknown>) => { | ||
handleRuffConfigChange(v); | ||
setVal(JSON.stringify(v, null, 2)); | ||
handleRuffSettingsClose(); | ||
}, | ||
[handleRuffConfigChange, handleRuffSettingsClose] | ||
|
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.
Is the argument mismatch in the JSON.stringify calls intentional?
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. I want to check if the value was reset to default here, but the objects won't be the same. The other option was to do this check in the settings modal before onSave is called and then call with null or undefined to indicate the default.
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.
Oh, I misread this. I thought your were passing in
undefined, 2
to one of the JSON.stringify calls