Skip to content

Comments

Fix for GUI not using pydantic. Also added feature for custom date co…#42

Merged
rtomek merged 2 commits intomasterfrom
feature/pip_support
Jan 14, 2026
Merged

Fix for GUI not using pydantic. Also added feature for custom date co…#42
rtomek merged 2 commits intomasterfrom
feature/pip_support

Conversation

@rtomek
Copy link
Collaborator

@rtomek rtomek commented Jan 14, 2026

…lumn

Copilot AI review requested due to automatic review settings January 14, 2026 21:11
@rtomek rtomek merged commit 10f5a7b into master Jan 14, 2026
0 of 3 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the GUI data source handling to use Pydantic's DataSourceConfig model instead of plain dictionaries, and adds support for custom date column configuration. The changes improve type safety and allow users to specify which column should be treated as the date column in CSV/TSV files.

Changes:

  • Updated Signal types to use DataSourceConfig instead of dict for type-safe data source emission
  • Added date_column field to DataSourceConfig with default value 'date' and alias 'date column'
  • Added UI field in CSV/TSV dialog for users to specify the date column name
  • Modified data source instantiation in file dialogs to create DataSourceConfig objects

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/midrc_react/gui/pyside6/jsdview.py Updated Signal type from dict to DataSourceConfig and added import
src/midrc_react/gui/pyside6/file_open_dialogs.py Added date_column UI field, updated file dialogs to create DataSourceConfig instances
src/midrc_react/gui/common/jsdview_base.py Updated Signal type from dict to DataSourceConfig and added import
src/midrc_react/core/jsdconfig.py Added date_column field with alias support to DataSourceConfig
src/midrc_react/core/excel_layout.py Added date column handling logic and return type annotation
Comments suppressed due to low confidence (1)

src/midrc_react/core/jsdconfig.py:60

  • In Pydantic v2, validate_by_name has been renamed to populate_by_name. Since the setup.py specifies pydantic>=2.7.0, you should use populate_by_name = True instead to follow Pydantic v2 conventions and avoid using deprecated configuration.
    class Config:
        validate_by_name = True

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

'remove column name text': dialog.remove_column_text_line_edit.text(),
}
self.add_data_source.emit(data_source_dict)
data_source_dict = dialog.get_data()
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FileOptionsDialog class does not have a get_data() method, but it's being called here. This will result in an AttributeError at runtime when opening Excel files. You need to either add a get_data() method to FileOptionsDialog that returns the necessary fields (name, description, remove_column_name_text), or directly access the dialog's line edit fields as was done in the previous implementation.

Suggested change
data_source_dict = dialog.get_data()
if hasattr(dialog, "get_data") and callable(getattr(dialog, "get_data", None)):
data_source_dict = dialog.get_data()
else:
# Fallback: construct the data source dict directly from dialog attributes
data_source_dict = {
"name": getattr(dialog, "name", ""),
"description": getattr(dialog, "description", ""),
"remove_column_name_text": getattr(dialog, "remove_column_name_text", ""),
}

Copilot uses AI. Check for mistakes.
Comment on lines +225 to +227
if self._date_column not in df.columns:
self._date_column = df.columns[0]
df.rename(columns={self._date_column: 'date'}, inplace=True) # Ensure the date column is named 'date'
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If self._date_column is None (which can happen since it's Optional[str] in DataSourceConfig), this will raise a TypeError when checking None not in df.columns. You should add a check to handle the None case, such as defaulting to 'date' or df.columns[0] before the comparison.

Suggested change
if self._date_column not in df.columns:
self._date_column = df.columns[0]
df.rename(columns={self._date_column: 'date'}, inplace=True) # Ensure the date column is named 'date'
# Determine which column to use as the date column, handling None and missing cases safely.
if self._date_column is not None and self._date_column in df.columns:
date_column = self._date_column
elif 'date' in df.columns:
# Prefer an existing 'date' column if present.
date_column = 'date'
else:
# Fallback: use the first column in the DataFrame.
date_column = df.columns[0]
# Update the stored date column name to the resolved value.
self._date_column = date_column
df.rename(columns={date_column: 'date'}, inplace=True) # Ensure the date column is named 'date'

Copilot uses AI. Check for mistakes.

from midrc_react.gui.pyside6.columnselectordialog import ColumnSelectorDialog, NumericColumnSelectorDialog

from midrc_react.core.jsdconfig import DataSourceConfig, NumericColumnConfig
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'NumericColumnConfig' is not used.

Suggested change
from midrc_react.core.jsdconfig import DataSourceConfig, NumericColumnConfig
from midrc_react.core.jsdconfig import DataSourceConfig

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant