Contributors mailing list archives

contributors@odoo-community.org

Avatar

Re: Escape python lint

by
Akretion France, David BEAL
- 24/10/2019 08:31:06
Thanks a lot Moise for you complete information


David BEAL - akretion.com
Chef de projet
Odoo Développement / Intégration


Le mer. 23 oct. 2019 à 21:46, Moises Lopez <moylop260@vauxoo.com> a écrit :
I have created the following script in a file:

```python
import logging

_logger = logging.getLogger(__name__)


query = """SELECT
'Hello World'"""
self.env.cr.execute(query)
_logger.warn("Query error %s", self.env.cr.query)
```

So, I called it using the following command:
`~/odoo-12.0/odoo-bin shell -d openerp_test --log-level=warn < query_test.py`

The output was:
Screen Shot 2019-10-23 at 14.40.31.png

Since that python3 is using bytes by default it is printed using bytes (Notice the "\n" instead of a real newline).

Using `print` the output is ignored for `--log-file=out.txt` parameter or a odoo started using a service.
So it is better using a logger.

But if you like skip this pylint check you can use a comment:
`# pylint: disable=print-used`

More info about:
 - https://docs.pylint.org/en/latest/faq.html#do-i-have-to-remember-all-these-numbers


El mié., 23 oct. 2019 a las 12:57, David Beal (<david.beal@akretion.com>) escribió:
Thanks Pedro.

For my information about ways to escape python lint.
- no way
- documented somewhere or example

Thanks

David BEAL

Le mer. 23 oct. 2019 à 19:12, Pedro M. Baeza (Tecnativa) <pedro.baeza@tecnativa.com> a écrit :
Answered in the PR as well: Why not emit it as logger.warning or similar?

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe



--
Moisés López Calderón
Mobile: (+521) 477-752-22-30
Twitter: @moylop260
hangout: moylop260@vauxoo.com
http://www.vauxoo.com - Odoo Gold Partner
Twitter: @vauxoo

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

Reference