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

False-positive DeprecationWarning #965

Open
ChrisLoveringSendient opened this issue Nov 29, 2024 · 1 comment
Open

False-positive DeprecationWarning #965

ChrisLoveringSendient opened this issue Nov 29, 2024 · 1 comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience

Comments

@ChrisLoveringSendient
Copy link

Describe the bug

Simply just importing one of the class request builders is enough to trigger a deprecation warnings. The reproduction steps below will output 3 different deprecation warnings, even though the deprecated classes are not being used.

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)

Expected behavior

Deprecation warnings are only raised when you insatiate a deprecated class I.E. are actually using it, not just importing it.

How to reproduce

python -Wd -c "from msgraph.generated.education.classes.classes_request_builder import ClassesRequestBuilder"

SDK Version

1.12.0

Latest version known to work for scenario above?

No response

Known Workarounds

Only workaround is to supress deprecation warnings from this library.

Debug output

Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_
@ChrisLoveringSendient ChrisLoveringSendient added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Nov 29, 2024
@Mrfence97
Copy link

FYI this is the new issue raised to handle @ChrisLoveringSendient's comment in #812.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

2 participants