-
Notifications
You must be signed in to change notification settings - Fork 37
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
Remove Problematic Type Union #694
Remove Problematic Type Union #694
Conversation
In the shell launcher, an unintended and unused type union sunk into the ``ShellLauncherCommand`` type for the ``command_tuple`` type, allowing the attr to be of type ``Sequence[str]`` or ``tuple[str, tuple[str, ...]]``. The former works as expected, but the latter would error at runtime when sent to the ``ShellLauncher`` when opening a subprocess. ```py class ShellLauncher: ... def start(self, shell_command: ShellLauncherCommand) -> LaunchedJobID: ... exe, *rest = shell_command.command_tuple # ^^^^ Mypy thinks this is `list[str] | list[tuple[str]]` expanded_exe = helpers.expand_exe_path(exe) # pylint: disable-next=consider-using-with self._launched[id_] = sp.Popen( (expanded_exe, *rest), # ^^^^^^^^^^^^^^^^^^^^^ # And inadvertently casts this to `tuple[Any]` which errors # at runtime cwd=shell_command.path, env={k: v for k, v in shell_command.env.items() if v is not None}, stdout=shell_command.stdout, stderr=shell_command.stderr, ) return id_ ``` Because this type was not being used, it can simply be removed from the union.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## smartsim-refactor #694 +/- ##
=====================================================
+ Coverage 40.45% 43.95% +3.49%
=====================================================
Files 110 110
Lines 7326 7134 -192
=====================================================
+ Hits 2964 3136 +172
+ Misses 4362 3998 -364
|
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.
LGTM!
@@ -57,7 +57,7 @@ class ShellLauncherCommand(t.NamedTuple): | |||
path: pathlib.Path | |||
stdout: io.TextIOWrapper | int | |||
stderr: io.TextIOWrapper | int | |||
command_tuple: tuple[str, tuple[str, ...]] | t.Sequence[str] |
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.
LGTM! Thanks for catching that.
In the shell launcher, an unintended and unused type union sunk into the
ShellLauncherCommand
type for thecommand_tuple
type, allowing the attr to be of typeSequence[str]
ortuple[str, tuple[str, ...]]
. The former works as expected, but the latter would error at runtime when sent to theShellLauncher
when opening a subprocess.Because this type was not being used, it can simply be removed from the union.