Skip to content

Conversation

achille-fouilleul
Copy link
Contributor

Quoting the python library documentation:

The subprocess module provides more powerful facilities for spawning
new processes and retrieving their results; using that module is
preferable to using this function.

return result


def tex_compilation_command(
Copy link
Contributor

@chopan050 chopan050 Oct 14, 2024

Choose a reason for hiding this comment

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

Since this function no longer returns a str with the TeX command, but instead returns a list[str] containing the command arguments, could we change this function's name to something like prepare_tex_compilation_args or prepare_tex_compilation_command_args?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the synopsys of subprocess.run, the name of the first and only positional argument, args, is a bit misleading because its first item is the command name. I think it follows the C language tradition where the first item of the argument vector (argv) of exec and main(int argc, char *argv[]) is the command name too.
If I saw a function named prepare_tex_compilation_command_args I would assume it returns the arguments only, not the command. I suggest we simply name this function make_tex_compilation_command.

Copy link
Contributor

Choose a reason for hiding this comment

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

make_tex_compilation_command sounds fine to me 👍

tex_compiler: str, output_format: str, tex_file: Path, tex_dir: Path
) -> str:
) -> list[str]:
"""Prepares the tex compilation command with all necessary cli flags
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""Prepares the tex compilation command with all necessary cli flags
"""Prepares a list of arguments for the TeX compilation command, with all necessary
CLI flags.

Returns
-------
:class:`str`
Compilation command according to given parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't select the line above this one (:class:`str`), but could you please change that one to :class:`list`[:class:`str`]?

Suggested change
Compilation command according to given parameters
A list of arguments for the TeX compilation command, according to the given parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating the type annotation, thanks. But I think the description is accurate. What is returned is really the full command, just in list form.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There must be an error in this part:

:class:`list`[:class:`str`]

The html output does not look correct in Firefox, something like list`[:class:`str]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The correct syntax seems to be:

:class:`list[str]`

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, I forgot that there was an issue with :class:`list`[:class:`str`].

The way Sphinx and Autodoc work for us is weird. When it autoinfers the return type from the typings, it doesn't seem to enclose the names with backticks, so if it autoinferred it would simply render list[str]. We do have a lot of explicit return types in docstrings enclosed in backticks, and they're rendered as inline code. That's an inconsistency which we should address at some point.

I would say, for the purpose of this PR, simply using list[str] would be fine.

Copy link
Contributor

@chopan050 chopan050 left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! I left some very minor changes regarding tex_compilation_command and its docstring.

@chopan050 chopan050 added pr:easy review There is nothing particular (i.e, it's about a general/small thing) to know for review! maintenance refactoring, typos, removing clutter/dead code, and other code quality improvements labels Oct 14, 2024
Quoting the python library documentation:

> The subprocess module provides more powerful facilities for spawning
> new processes and retrieving their results; using that module is
> preferable to using this function.
@achille-fouilleul achille-fouilleul force-pushed the move-from-os-system-to-subprocess branch from 55434cf to e7b4ba3 Compare October 15, 2024 22:21
@achille-fouilleul
Copy link
Contributor Author

To avoid confusion I renamed variable args to command.

Copy link
Contributor

@chopan050 chopan050 left a comment

Choose a reason for hiding this comment

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

LGTM!

@chopan050 chopan050 merged commit 0a96aac into ManimCommunity:main Oct 15, 2024
17 of 18 checks passed
@achille-fouilleul achille-fouilleul deleted the move-from-os-system-to-subprocess branch October 16, 2024 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance refactoring, typos, removing clutter/dead code, and other code quality improvements pr:easy review There is nothing particular (i.e, it's about a general/small thing) to know for review!

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants