You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Python_sml_ClientInterface module generated by SWIG provides C++ style function declarations in the
generated comments but does not declare Python type signatures. As a result, features that depend on Python
declarations will not work. This includes type checking from lint tools like mypy or pyright as well as autocompletion
features from various IDEs that support Python.
One workaround for this is to provide a parallel Python_sml_ClientInterface.pyi file that provides cleaned up
doc strings and type signatures. This will be used by the IDE and type checking tools but will not affect the actual
runtime behavior. You could simply copy the generated SWIG interface file, delete the runtime code, tweak
the docstrings to be more python-friendly, and adding type signatures.
For instance, the generated CreateAgent method is:
defCreateAgent(self, name: str, /) ->str:
r""" Args: name: name for agent """
Note: the point of the / is to disable use of keyword argument invocation in the declaration since
this changes the name of the argument name from the actual declaration. If we think that users will
want to use keyword argument invocations, then we can keep the existing name (even though the
names will be awkward in Python).
Obviously, such a file would have to be updated if/when the generated SWIG interface changes, but it would definitely help productivity for any Python SML users.
Also note, that an interface file like this could actually be provided by a standalone Python package and does not necessarily need to be part of the main release.
The text was updated successfully, but these errors were encountered:
Not having typing is one of my major gripes with SWIG. A type stubs file would be a nice fix! The one drawback being, of course, that it will be easy to accidentally let it go out of date.
I think Copilot could probably generate a lot of the file, as well.
The
Python_sml_ClientInterface
module generated by SWIG provides C++ style function declarations in thegenerated comments but does not declare Python type signatures. As a result, features that depend on Python
declarations will not work. This includes type checking from lint tools like mypy or pyright as well as autocompletion
features from various IDEs that support Python.
One workaround for this is to provide a parallel
Python_sml_ClientInterface.pyi
file that provides cleaned updoc strings and type signatures. This will be used by the IDE and type checking tools but will not affect the actual
runtime behavior. You could simply copy the generated SWIG interface file, delete the runtime code, tweak
the docstrings to be more python-friendly, and adding type signatures.
For instance, the generated
CreateAgent
method is:this could be changed to something like:
Note: the point of the
/
is to disable use of keyword argument invocation in the declaration sincethis changes the name of the argument name from the actual declaration. If we think that users will
want to use keyword argument invocations, then we can keep the existing name (even though the
names will be awkward in Python).
Obviously, such a file would have to be updated if/when the generated SWIG interface changes, but it would definitely help productivity for any Python SML users.
Also note, that an interface file like this could actually be provided by a standalone Python package and does not necessarily need to be part of the main release.
The text was updated successfully, but these errors were encountered: