Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][REF] l10n_br_account_payment_brcobranca: Resolvendo erros PEP8 validados em versões recentes #3287

Merged
merged 2 commits into from
Aug 16, 2024

Conversation

mbcosta
Copy link
Contributor

@mbcosta mbcosta commented Aug 14, 2024

Refactoring to solve PEP8 errors in the v16 pre-commit.

Resolvendo erros PEP8 validados em versões recentes do pre-commit v15 v16:

  • [W8138(except-pass), PaymentOrder.generate_payment_file] pass into block except. If you really need to use the pass consider logging that exception

Para resolver esse erro foi incluído o logger.Warning no PR #3225

WARNING odoo odoo.addons.l10n_br_account_payment_brcobranca.models.account_payment_line: Error executing method _prepare_bank_line_caixa.Check the bank name and provided parameters. 
Traceback (most recent call last):
  File "/odoo/external-src/l10n-brazil/l10n_br_account_payment_brcobranca/models/account_payment_line.py", line 127, in prepare_bank_payment_line
    self, f"_prepare_bank_line_{bank_name_brcobranca.name}"


WARNING odoo odoo.addons.l10n_br_account_payment_brcobranca.models.account_payment_line: Error executing method _prepare_bank_line_ailos.Check the bank name and provided parameters. 
Traceback (most recent call last):
  File "/odoo/external-src/l10n-brazil/l10n_br_account_payment_brcobranca/models/account_payment_line.py", line 127, in prepare_bank_payment_line
    self, f"_prepare_bank_line_{bank_name_brcobranca.name}"
AttributeError: 'account.payment.line' object has no attribute '_prepare_bank_line_ailos'

Mas é desnecessário, acredito que esse TRY foi incluído para evitar a necessidade de vários IF, lendo sobre o porque isso retorna erro pelo o que entendi é que sempre que acontecer "algo inesperado" o código precisar tratar esses casos e não apenas ignorar, uma referencia https://stackoverflow.com/questions/21553327/why-is-except-pass-a-bad-programming-practice , mas aqui não precisamos do TRY porque já sabemos os casos em que existe um método especifico então um simples IF resolve, com isso LOG também volta a ficar limpo.

  • [E8106(external-request-timeout), CNABFileParser._get_brcobranca_retorno] Use of external request method requests.post without timeout. It could wait for a long time

Aqui tem apenas uma questão que é saber se o valor 5 está razoável? Ou outro valor? Ou se isso deveria ser um parâmetro para permitir alterações?

cc @rvalyi @renatonlima @marcelsavegnago @mileo @antoniospneto @kaynnan

@OCA-git-bot
Copy link
Contributor

Hi @rvalyi,
some modules you are maintaining are being modified, check this out!

…pass) PEP8 was included logger.Warning but is unnecessary use TRY for this because there no unexpect error, the code already know the Banks that need a specific method.
…st-timeout) Use of external request method without timeout. It could wait for a long time.'
@rvalyi
Copy link
Member

rvalyi commented Aug 16, 2024

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 14.0-ocabot-merge-pr-3287-by-rvalyi-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 4e5d4d9 into OCA:14.0 Aug 16, 2024
6 of 7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 8a4539f. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants