Skip to main content

inspecao

CI PyPI Python License: MIT

Inspeção de peças com regras declarativas, armazenamento em caixas e relatório — sem dependências.

A ideia é simples: você descreve o que é uma peça aprovada, o pacote aplica as regras, coleta todos os motivos de reprovação (não para no primeiro erro), guarda as aprovadas em caixas com capacidade fixa e fecha o relatório.

Instalação

pip install inspecao

Requer Python 3.10+.

Uso rápido

from inspecao import Armazem, Conjunto, Faixa, Inspecao, Peca, Relatorio

inspecao = Inspecao(
    [
        Faixa("peso", 95, 105, unidade="g"),
        Conjunto("cor", {"azul", "verde"}),
        Faixa("comprimento", 10, 20, unidade="cm"),
    ]
)

peca = Peca("QL-001", peso=100, cor="Azul", comprimento=15)
resultado = inspecao.avaliar(peca)

resultado.aprovado  # True
resultado.motivos  # ()

Uma peça reprovada acumula todos os problemas:

reprovada = inspecao.avaliar(Peca("QL-015", peso=110, cor="amarela", comprimento=25))
reprovada.campos_reprovados
# ('peso', 'cor', 'comprimento')
print("\n".join(reprovada.motivos))
# Peso de 110 g fora da faixa de 95 g a 105 g.
# Cor 'amarela' não permitido. Aceitos: azul, verde.
# Comprimento de 25 cm fora da faixa de 10 cm a 20 cm.

Armazenamento em caixas

armazem = Armazem(capacidade=10)

for numero in range(1, 13):
    evento = armazem.adicionar(Peca(f"QL-{numero:03d}", peso=100))
    if evento.fechou:
        print(f"caixa {evento.caixa.numero} fechou com {evento.caixa.ocupacao} peças")

armazem.caixas_fechadas  # (Caixa(numero=1, ...),)
armazem.caixa_aberta  # Caixa(numero=2, ocupacao=2)
armazem.caixas_usadas  # 2

Relatório

relatorio = Relatorio.de(inspecao.avaliar_lote(pecas), armazem)
relatorio.como_dict()
# {'total': 16, 'aprovadas': 12, 'reprovadas': 4,
#  'por_motivo': {'comprimento': 2, 'cor': 2, 'peso': 2},
#  'reprovadas_pecas': ['QL-016', 'QL-015', ...],
#  'caixas_fechadas': 1, 'caixas_usadas': 2}

Linha de comando

inspecao avaliar --id QL-001 --peso 100 --cor azul --comprimento 15
# QL-001: aprovada

inspecao lote pecas.csv --capacidade 10
# Total: 3
# Aprovadas: 1
# ...

O CSV precisa das colunas identificador,peso,cor,comprimento. O comando avaliar sai com código 1 quando a peça é reprovada, o que permite usar em pipeline.

inspecao lote pecas.csv --json --quieto | jq .reprovadas

Regras da CLI padrão

Campo Regra
peso entre 95 g e 105 g (inclusive)
cor azul ou verde, sem diferenciar maiúsculas
comprimento entre 10 cm e 20 cm (inclusive)

Na API Python as regras são suas: Faixa, Conjunto ou qualquer objeto que implemente o protocolo Criterio.

Critérios personalizados

from inspecao import Falha


class Par:
    """Exige que o campo seja um número par."""

    def __init__(self, campo: str) -> None:
        self.campo = campo

    def avaliar(self, valor):
        if valor is None or valor % 2:
            return Falha(self.campo, valor, f"{self.campo} precisa ser par.")
        return None

Documentação

Licença

MIT — veja LICENSE.

Metadata

Release files for inspecao 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for inspecao 0.1.0
File Size Uploaded Provenance Actions
inspecao-0.1.0.tar.gz 13.6 kB With provenance Details for inspecao-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for inspecao 0.1.0
File Interpreter ABI Platform Actions
inspecao-0.1.0-py3-none-any.whl Python 3 none any Details for inspecao-0.1.0-py3-none-any.whl

Total release size: 25.4 kB

Release files / inspecao-0.1.0.tar.gz

Download URL inspecao-0.1.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4036298414bb75dc054c56b6f31faeb5004164029c2b36d1a1faf2cba3deab7c
BLAKE2b-256 checksum
How to use checksums
8ecbe25a7437597747d3ec926b5ef345ac3e40096a435e93380763f09014760e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / inspecao-0.1.0-py3-none-any.whl

Download URL inspecao-0.1.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
464082c9e99e87b168ab85f8747cf4e2c26c373519a5c0b75e3599bbee77b394
BLAKE2b-256 checksum
How to use checksums
13a9fafa3d27da5ad448fb2a3533dce75b651fe43f9778e17774399bffa4dc26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for inspecao 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for inspecao-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page