Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

would be nice if `Info.info()` accepted non-`str` types in the given `dict`

Aberta
#1,046 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
35/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
python
Domínio
observability

Direção de pesquisa

Comece localizando a implementação de Info.info() e os testes existentes e, em seguida, reproduza a falha relatada com um dict contendo valores dos tipos float, int e bool. O trabalho estará concluído quando valores não string compatíveis forem aceitos com uma representação definida e os testes cobrirem o comportamento de conversão.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Hey.

Right now, when one feeds a dict into Info.info()that contains values that are notstr` one get's an exception, like:

AttributeError: ("'float' object has no attribute 'replace'", Metric(smart_array, blafasl, info, , [Sample(name='smart_array_info', labels={'slot': '0', 'serial_number': 'xxx', 'controller_status': 'OK', 'hardware_revision': 'B', 'firmware_version': '6.60', 'rebuild_priority': 'High', 'cache_status': 'OK', 'battery_capacitor_status': 'OK', 'controller_temperature_celsius': 49.0, 'cache_module_temperature_celsius': 38.0, 'model': 'Smart Array P840ar'}, value=1.0, timestamp=None, exemplar=None)]))

IMO it woud be nice if that would accept at least other base Python types like int, float and bool and convert these automatically do a suitable representation (which is obvious, I guess, expect perhaps for bool , where one could go by 0/1 (guess that should be it) or True/False/etc.).

Stripping off \n and the likes wouldn't be needed for those types anyway.

Perhaps one could make it generic? Only if the value is an instance of str, try to .replace(...) in all other cases, make a str() out of it?

Maybe with an exception for bool if 0/1 shall be used.

Cheers,
Chris.

Linguagem predominante
Python
Estrelas
4.4k
Forks
876
Merge médio
8d 4h
PRs com merge (30d)
1

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de prometheus/client_python

Todas as issues de prometheus/client_python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.