ENH: log exception filename/line number#65
Conversation
| import types | ||
| import typing | ||
| import warnings | ||
| from typing import Optional, Tuple, Union |
There was a problem hiding this comment.
Is there a reason we take out the typing. for some of the type hints but not all of them? Are hints like TextIO considered not well-known enough to omit the parent package?
There was a problem hiding this comment.
A good reason? No. I tend to go back and forth and annoy reviewers with this.
- I like to import the common ones by name
Tuple,Union,Listare used everywhere (to reduce typing) - Uncommon ones or those that get used perhaps once like
TextIOI tend to do with the qualified name - i.e.,typing.TextIO
The stylistic issue of which to choose will go away at some point when we are on 3.9+ everywhere (since we can do list[int] instead of typing.List[int])
There was a problem hiding this comment.
I typically just from typing import x for all of them.
In general I'm pretty happy with using from imports for everything except when the context is important to understanding the code. For example, if there was a common namespace collision I'd probably avoid the from import...
It's not very important in most cases I think.
There was a problem hiding this comment.
I also avoid from imports when the function name is super generic... like post or read or something like that. modulename.post is much clearer in the code.
There was a problem hiding this comment.
Other random ones, not talking about typing.X specifically:
- It's easier to monkeypatch at a module level when using
module.obj - It's easier to grep for usage when you have
module.obj
In general I think import module; module.obj is superior in most ways, except when used excessively that it makes the code unnecessarily long.
tangkong
left a comment
There was a problem hiding this comment.
Adding some extra fields to the json, looks simple enough. Shows up in grafana too 👍
Description
Add
exc_filenameandexc_lineto global log JSON.Motivation and Context
Closes #63
How Has This Been Tested?
Where Has This Been Documented?
Issue and PR
Screenshots (if appropriate):
Related but not dependent: pcdshub/hutch-python#346