microsoftgraph / microsoftgraph/msgraph-sdk-python
False-positive DeprecationWarning
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 630
- Forks
- 96
- Merge médio
- 15h 20min
- PRs com merge (30d)
- 3
Descrição
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_
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece com kiota_abstractions.default_query_parameters.py e reproduza o aviso usando o comando de importação Python fornecido. Verifique como as classes de request-builder obsoletas emitem avisos durante a definição da classe e, em seguida, confirme que importar ClassesRequestBuilder não gera nenhum aviso, enquanto instanciar uma classe obsoleta continua gerando um aviso.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- api
- Tipo de issue
- Bug
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 45/100