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

[IMP] Adding exception section for good practice #252

Merged

Conversation

JesusZapata
Copy link
Member

The pass into block except is not a good practice!

By including the pass we assume that our algorithm can continue to function after the exception occurred

If you really need to use the pass consider logging that exception

    try:
        sentences
    except:
        pass
        _logger.debug('Pass')

try:
sentences
except:
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove pass
If you use a sentence after pass then is not need it

Copy link
Contributor

@lasley lasley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment but otherwise 👍

If you really need to use the `pass` consider logging that exception

```python
try:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to reduce the indentation level by one, this is double indented in the example block right now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks for your comment!

@moylop260
Copy link
Contributor

@lmignon Are you agree with this guideline (and future check)?

@moylop260
Copy link
Contributor

@yajo @pedrobaeza Your feedback is welcome

@lmignon
Copy link
Sponsor Contributor

lmignon commented Jan 17, 2017

In some cases It could be useful to properly log the exception with the stacktrace.. (That depends of the context.)

    try:
        sentences
    except:
        _logger.debug('Why the exception is safe....', exc_info=1))

try:
sentences
except:
_logger.debug('Pass')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please switch to a lowercase L. _logger

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, what uppercase L are you referring?

Copy link
Contributor

@lasley lasley Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow ok sorry, this is totally just something with Github display & not something you did (it's a lowercase l looking at the code in IDE).

Just so you know I'm not crazy though, this looks like some sort of uppercase unicode L derivate. Something with the font of the italics I guess:

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! dont worry
Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a auto-translator enabled from your browser?

@moylop260
Copy link
Contributor

@JesusZapata
Could you add exc_info=1 like as #252 (comment)?

@JesusZapata
Copy link
Member Author

@moylop260 @lmignon Done!
Thanks for you comments!

@moylop260 moylop260 merged commit 71871be into OCA:master Jan 18, 2017
@moylop260 moylop260 deleted the master-add-except-pass-to-docs-oca-jesuszapata branch January 18, 2017 01:06
@JesusZapata
Copy link
Member Author

JesusZapata commented Jan 18, 2017

@moylop260
I have registered a PR OCA/pylint-odoo#107 related to this documentation!

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

Successfully merging this pull request may close these issues.

5 participants