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

_request_builder.py DeprecationWarning: This class is deprecated. Please use the generic RequestConfiguration class generated by the generator #812

Closed
drernie opened this issue Jul 12, 2024 · 5 comments
Assignees
Labels
status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience

Comments

@drernie
Copy link

drernie commented Jul 12, 2024

Describe the bug

Maybe not an actual bug, but every time I use a _request_builder I get a warning like:

:943: DeprecationWarning: This class is deprecated. Please use the generic RequestConfiguration class generated by the generator

It appears I can use:

from kiota_abstractions.base_request_configuration import RequestConfiguration

But there doesn't seem to be any other way to get the RequestBuilderGetQueryParameters class other than by instantiating the specific version, e.g. UserItemRequestBuilder.UserItemRequestBuilderGetQueryParameters.

Expected behavior

Either:

  1. No deprecation warning
  2. A code change I can make to avoid that deprecation warning
  3. A clear signal that this is an underlying library issue that is not my fault

How to reproduce

This showed up when pasting in code directly from the Tutorial:

https://learn.microsoft.com/en-us/graph/tutorials/python?tabs=aad&tutorial-step=4

SDK Version

1.5.2

Latest version known to work for scenario above?

No response

Known Workarounds

I can just ignore it...

Debug output

Click to expand log ``` ../../Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/kiota_abstractions/default_query_parameters.py:23 /Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/kiota_abstractions/default_query_parameters.py:23: DeprecationWarning: GetQueryParameters is deprecated. Use QueryParameters instead. warn("GetQueryParameters is deprecated. Use QueryParameters instead.", DeprecationWarning)

../../Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/item/mail_folders/item/messages/messages_request_builder.py:208
/Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/item/mail_folders/item/messages/messages_request_builder.py:208: DeprecationWarning: This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.
warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)

../../Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/item/mail_folders/item/messages/messages_request_builder.py:215
/Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/item/mail_folders/item/messages/messages_request_builder.py:215: DeprecationWarning: This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.
warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)

../../Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/item/user_item_request_builder.py:910
/Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/item/user_item_request_builder.py:910: DeprecationWarning: This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.
warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)

../../Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/item/user_item_request_builder.py:943
/Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/item/user_item_request_builder.py:943: DeprecationWarning: This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.
warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)

../../Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/item/user_item_request_builder.py:950
/Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/item/user_item_request_builder.py:950: DeprecationWarning: This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.
warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)

../../Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/sites/sites_request_builder.py:200
/Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/sites/sites_request_builder.py:200: DeprecationWarning: This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.
warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)

</details>


### Configuration

macOS ARM (M3)

### Other information

_No response_
@drernie drernie added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jul 12, 2024
@rkodev rkodev self-assigned this Jul 12, 2024
@drernie
Copy link
Author

drernie commented Jul 12, 2024

FYI, I discovered I could reduce (but not quite eliminate) the warnings by getting the classes from the "client" rather than importing them manually, e.g.:

        query_params = self.client.me.UserItemRequestBuilderGetQueryParameters(
            select=["displayName", "mail", "userPrincipalName"]
        )

        request_config = RequestConfiguration(query_parameters=query_params)

Now I only get 5 (versus 7) warnings. The remainder feels more like a wart in the underlying code generation, than a bug in mine, so I won't spend any more time on this unless you have questions.

Click to expand log ``` /Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msal/token_cache.py:156: DeprecationWarning: Use list(search(...)) instead to explicitly get a list. warnings.warn(

tests/test_graph.py::test_graph_get_users
/Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/kiota_abstractions/default_query_parameters.py:23: DeprecationWarning: GetQueryParameters is deprecated. Use QueryParameters instead.
warn("GetQueryParameters is deprecated. Use QueryParameters instead.", DeprecationWarning)

tests/test_graph.py::test_graph_get_users
/Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/users_request_builder.py:235: DeprecationWarning: This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.
warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)

tests/test_graph.py::test_graph_get_users
/Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/users/users_request_builder.py:242: DeprecationWarning: This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.
warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)

tests/test_sites.py::test_sites
/Users/ernest/Library/Caches/pypoetry/virtualenvs/sharepoint-python-test-FDvtzw7U-py3.12/lib/python3.12/site-packages/msgraph/generated/sites/sites_request_builder.py:200: DeprecationWarning: This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.
warn("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.", DeprecationWarning)

</details>

@shaneseaton
Copy link

Yep, this is annoying me too.

@shemogumbe shemogumbe assigned shemogumbe and unassigned rkodev Aug 6, 2024
@shemogumbe
Copy link
Collaborator

Hello @drernie and @shaneseaton Thanks for using the SDK and for raising this.

These changes occured during the move from V1.3.0 to V1.4.0

Part of the reason was to help with code quantity reduction and help us use more abstract classes for ease of customization.

The PR on this is microsoft/kiota#4578

Note that you can use both the RequestBuilderConfiguration though deprecated, or the custome abstraction class as show in the PR.

@shemogumbe shemogumbe added status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned labels Aug 6, 2024
@ChrisLoveringSendient
Copy link

Simply just importing one of the class request builders is enough to trigger these warnings.

python -Wd -c "from msgraph.generated.education.classes.classes_request_builder import ClassesRequestBuilder" will output 3 different deprecation warnings, even though they're not being called directly.

This is because the warnings are in the class scope, so will be ran at "compile" time.
Changing the first example to the second will only warn when the dataclass is instantiated.

# kiota_abstractions.default_query_parameters.py
@dataclass
class GetQueryParameters(QueryParameters):
    """
    Default placeholder class for query parameters.
    """
    warn("GetQueryParameters is deprecated. Use QueryParameters instead.", DeprecationWarning)
# kiota_abstractions.default_query_parameters.py
@dataclass
class GetQueryParameters(QueryParameters):
    """
    Default placeholder class for query parameters.
    """
    def __init__(self, *args, **kwargs):
        warn("GetQueryParameters is deprecated. Use QueryParameters instead.", DeprecationWarning)
        super().__init__(*args, **kwargs)

@ChrisLoveringSendient
Copy link

ChrisLoveringSendient commented Nov 22, 2024

Hi @shemogumbe can we reopen this issue, or should I create a new one?

EDIT: See #965

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

5 participants