microsoftgraph / microsoftgraph/msgraph-sdk-python

False-positive DeprecationWarning

Aperta
#965 3 commenti 10 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

area:documentation priority:p2
Lingua principale
Python
Stelle
630
Fork
96
Merge medio
15h 20m
PR unite (30g)
3

Descrizione

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 instantiate 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 suppress deprecation warnings from this library.

import warnings

warnings.filterwarnings("ignore", module="msgraph", category=DeprecationWarning)
warnings.filterwarnings(
    "ignore",
    module="kiota_abstractions",
    category=DeprecationWarning,
)
Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con kiota_abstractions.default_query_parameters.py e riproduci l’avviso usando il comando di importazione Python fornito. Verifica come le classi request-builder deprecate emettono avvisi durante la definizione della classe, quindi verifica che l’importazione di ClassesRequestBuilder non produca avvisi, mentre l’istanziazione di una classe deprecata continui a produrre un avviso.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.