lipe14-ops / brasilapy

Brasil API client
MIT License
91 stars 21 forks source link

TypeError: unsupported operand type(s) for |: 'type' and 'NoneType' #10

Closed WellingtonFonseca closed 1 year ago

WellingtonFonseca commented 1 year ago

pessoal, não estou conseguindo utilizar a lib, pois está informando erro de declaração.

Traceback (most recent call last):
  File "/home/usuario/programacao/python/django/regionalspc/application/teste.py", line 5, in <module>
    from brasilapy import BrasilAPI
  File "/home/usuario/programacao/python/django/regionalspc/application/venv/lib/python3.9/site-packages/brasilapy/__init__.py", line 1, in <module>
    from .client import BrasilAPI  # noqa: F401
  File "/home/usuario/programacao/python/django/regionalspc/application/venv/lib/python3.9/site-packages/brasilapy/client.py", line 2, in <module>
    from brasilapy.models.cnpj import CNPJ
  File "/home/usuario/programacao/python/django/regionalspc/application/venv/lib/python3.9/site-packages/brasilapy/models/cnpj.py", line 3, in <module>
    from .general import BaseReturnModel
  File "/home/usuario/programacao/python/django/regionalspc/application/venv/lib/python3.9/site-packages/brasilapy/models/general.py", line 12, in <module>
    class Bank(BaseReturnModel):
  File "/home/usuario/programacao/python/django/regionalspc/application/venv/lib/python3.9/site-packages/brasilapy/models/general.py", line 15, in Bank
    code: int | None
TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'

analisando, aqui ele direciona para o variável code

class Bank(BaseReturnModel):
    ispb: str
    name: str
    code: int | None
    fullName: str
$ python
Python 3.9.13 (main, May 23 2022, 22:01:06) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 
$ poetry show
anyio                        3.6.1       High level compatibility layer for multiple asynchronous event loo...
APScheduler                  3.9.1       In-process task scheduler with Cron-like capabilities
asgiref                      3.5.2       ASGI specs, helper code, and adapters
async_generator              1.10        Async generators and context managers for Python 3.5+
attrs                        22.1.0      Classes Without Boilerplate
autopep8                     1.7.0       A tool that automatically formats Python code to conform to the PE...
brasilapy                    1.2.1       Brasil API Client for Python
cachetools                   5.2.0       Extensible memoizing collections and decorators
certifi                      2022.9.24   Python package for providing Mozilla's CA Bundle.
cffi                         1.15.1      Foreign Function Interface for Python calling C code.
charset-normalizer           2.1.1       The Real First Universal Charset Detector. Open, modern and active...
commonmark                   0.9.1       Python parser for the CommonMark Markdown spec
contourpy                    1.0.5       Python library for calculating contours of 2D quadrilateral grids
cryptography                 38.0.1      cryptography is a package which provides cryptographic recipes and...
cycler                       0.11.0      Composable style cycles
Django                       4.1.1       A high-level Python web framework that encourages rapid developmen...
et-xmlfile                   1.1.0       An implementation of lxml.xmlfile for the standard library
exceptiongroup               1.0.0rc9    Backport of PEP 654 (exception groups)
flake8                       5.0.4       the modular source code checker: pep8 pyflakes and co
fonttools                    4.37.4      Tools to manipulate font files
geographiclib                2.0         The geodesic routines from GeographicLib
geopy                        2.3.0       Python Geocoding Toolbox
h11                          0.12.0      A pure-Python, bring-your-own-I/O implementation of HTTP/1.1
httpcore                     0.15.0      A minimal low-level HTTP client.
httpx                        0.23.0      The next generation HTTP client.
idna                         3.4         Internationalized Domain Names in Applications (IDNA)
imgkit                       1.2.2       Wkhtmltopdf python wrapper to convert html to image using the webk...
iniconfig                    1.1.1       iniconfig: brain-dead simple config-ini parsing
Jinja2                       3.1.2       A very fast and expressive template engine.
kiwisolver                   1.4.4       A fast implementation of the Cassowary constraint solver
MarkupSafe                   2.1.1       Safely add untrusted strings to HTML/XML markup.
matplotlib                   3.6.1       Python plotting package
mccabe                       0.7.0       McCabe checker, plugin for flake8
msal                         1.19.0      The Microsoft Authentication Library (MSAL) for Python library ena...
mypy                         0.971       Optional static typing for Python
mypy-extensions              0.4.3       Experimental type system extensions for programs checked with the ...
mysql-connector-python       8.0.30      MySQL driver written in Python
mysqlclient                  2.1.1       Python interface to MySQL
numpy                        1.23.3      NumPy is the fundamental package for array computing with Python.
Office365-REST-Python-Client 2.3.14      Microsoft 365 & Microsoft Graph Library for Python
openpyxl                     3.0.10      A Python library to read/write Excel 2010 xlsx/xlsm files
outcome                      1.2.0       Capture the outcome of Python function calls.
packaging                    21.3        Core utilities for Python packages
pandas                       1.5.0       Powerful data structures for data analysis, time series, and stati...
pendulum                     2.1.2       Python datetimes made easy
Pillow                       9.2.0       Python Imaging Library (Fork)
pluggy                       1.0.0       plugin and hook calling mechanisms for python
protobuf                     3.20.1      Protocol Buffers
py                           1.11.0      library with cross-python path, ini-parsing, io, code, log facilities
pyaes                        1.6.1       Pure-Python Implementation of the AES block-cipher and common mode...
pyasn1                       0.4.8       ASN.1 types and codecs
pycodestyle                  2.9.1       Python style guide checker
pycparser                    2.21        C parser in Python
pydantic                     1.10.2      Data validation and settings management using python type hints
pyflakes                     2.5.0       passive checker of Python programs
Pygments                     2.13.0      Pygments is a syntax highlighting package written in Python.
PyJWT                        2.5.0       JSON Web Token implementation in Python
pyparsing                    3.0.9       pyparsing module - Classes and methods to define and execute parsi...
PySocks                      1.7.1       A Python SOCKS client module. See https://github.com/Anorov/PySock...
pytest                       7.1.3       pytest: simple powerful testing with Python
pytest-django                4.5.2       A Django plugin for pytest.
python-dateutil              2.8.2       Extensions to the standard Python datetime module
python-dotenv                0.21.0      Read key-value pairs from a .env file and set them as environment ...
python-telegram-bot          20.0a4      We have made you a wrapper you can't refuse
pytz                         2022.2.1    World timezone definitions, modern and historical
pytz-deprecation-shim        0.1.0.post0 Shims to make deprecation of pytz easier
pytzdata                     2020.1      The Olson timezone database for Python.
requests                     2.28.1      Python HTTP for Humans.
rfc3986                      1.5.0       Validating URI References per RFC 3986
rich                         12.5.1      Render rich text, tables, progress bars, syntax highlighting, mark...
rsa                          4.9         Pure-Python RSA implementation
selenium                     4.5.0       
setuptools                   65.4.1      Easily download, build, install, upgrade, and uninstall Python pac...
setuptools-scm               7.0.5       the blessed package to manage your versions by scm tags
six                          1.16.0      Python 2 and 3 compatibility utilities
sniffio                      1.3.0       Sniff out which async library your code is running under
sortedcontainers             2.4.0       Sorted Containers -- Sorted List, Sorted Dict, Sorted Set
sqlparse                     0.4.3       A non-validating SQL parser.
Telethon                     1.25.2      Full-featured Telegram client library for Python 3
toml                         0.10.2      Python Library for Tom's Obvious, Minimal Language
tomli                        2.0.1       A lil' TOML parser
tornado                      6.2         Tornado is a Python web framework and asynchronous networking libr...
trio                         0.22.0      A friendly Python library for async concurrency and I/O
trio-websocket               0.9.2       WebSocket library for Trio
types-cryptography           3.3.23      Typing stubs for cryptography
types-requests               2.28.11     Typing stubs for requests
types-urllib3                1.26.25     Typing stubs for urllib3
typing-extensions            4.3.0       Backported and Experimental Type Hints for Python 3.7+
tzdata                       2022.4      Provider of IANA time zone data
tzlocal                      4.2         tzinfo object for the local timezone
Unidecode                    1.3.6       ASCII transliterations of Unicode text
urllib3                      1.26.12     HTTP library with thread-safe connection pooling, file post, and m...
validate-docbr               1.10.0      Validate brazilian documents.
wheel                        0.37.1      A built-package format for Python
wsproto                      1.2.0       WebSockets state-machine based protocol implementation
XlsxWriter                   3.0.3       A Python module for creating Excel XLSX files.
lipe14-ops commented 1 year ago

OLÁ @WellingtonFonseca!!! Tudo jóia???

pelo o que percebi este erro está relacionado a versão do python que você está usando. A nossa lib é apenas compativel com versões do python 3.10+ (você está usando a versão 3.9.13)

para solucionar se basta atualizar a versão de seu python se possivel...

espero ter ajudado... E obrigado por reportar o erro!!! :)

WellingtonFonseca commented 1 year ago

caraca, me perdoe, não havia notado essa informação na documentação. no caso vou manter a minha versão, pois o projeto ainda está na metade e não posso retroceder (caso seja necessário) para resolver bugs.

muito obrigado