Skip to content
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

Mypy and autorest #302

Open
chaen opened this issue Sep 25, 2024 · 0 comments
Open

Mypy and autorest #302

chaen opened this issue Sep 25, 2024 · 0 comments

Comments

@chaen
Copy link
Contributor

chaen commented Sep 25, 2024

Autorest is tricky for mypy because it dynamically loads up patches.
While trying to bend the arms of both of them to get something sensible, I saw that there is a post processing step of autorest which should solve our problem:

https://github.com/Azure/autorest.python/blob/main/docs/customizations.md#postprocessing-optional

It's being used by Azure:
https://github.com/Azure/azure-sdk-for-python/blob/200f57e6459a5b5a240e76bb2d661e5cc17181b1/tools/azure-sdk-tools/packaging_tools/generate_client.py#L26C42-L26C53

Azure/azure-sdk-for-python#34695
Not perfect though...
Azure/autorest.python#1465

If I try to run it now, I get

$ autorest --python --postprocess --output-folder="/home/chaen/dirac/diracx-project/diracx/diracx-client/src/diracx/client/generated" --namespace=generated
AutoRest code generation utility [cli version: 3.7.1; node: v22.9.0]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info    | AutoRest core version selected from configuration: ^3.7.0.
(node:275682) [DEP0060] DeprecationWarning: The `util._extend` API is deprecated. Please use Object.assign() instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
info    |    Loading AutoRest core      '/home/chaen/.autorest/@[email protected]/nodemodules/@autorest/core/dist' (3.10.0)
info    |    Loading AutoRest extension '@autorest/python' (latest->6.23.0)
info    |    Loading AutoRest extension '@autorest/modelerfour' (~4.23.5->4.23.7)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/chaen/.autorest/@[email protected]/node_modules/@autorest/python/generator/pygen/postprocess/get_all.py", line 16, in <module>
    patched = ",".join(main(sys.argv[1]))
                       ^^^^^^^^^^^^^^^^^
  File "/home/chaen/.autorest/@[email protected]/node_modules/@autorest/python/generator/pygen/postprocess/get_all.py", line 11, in main
    sdk = importlib.import_module(namespace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chaen/mambaforge/envs/gubbins-dev/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1384, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1298, in _sanity_check
ValueError: Empty module name
Error: Command failed: python3 ./scripts/start.py
fatal   | Process() cancelled due to failure 
error   | [Exception] AutoRest extension '@autorest/python' terminated.
error   |   Error: [Exception] AutoRest extension '@autorest/python' terminated.
error   | Autorest completed with an error. If you think the error message is unclear, or is a bug, please declare an issues at https://github.com/Azure/autorest/issues with the error message you are seeing.

To be investigated

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

No branches or pull requests

1 participant