-
Notifications
You must be signed in to change notification settings - Fork 34
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
Ruff settings #927
Comments
added |
Slows down pyblish plugins logging. Also when using dict/list/more complex objects, you have to explicitly convert it to string. |
How does it slow it down? Because it should speed it up because it'd skip formatting logs that remain unhandled. I mean, technically it could be slower because we just happen to capture ALL logs.
Regarding this - I believe that's actually an issue of how the 'logs' are handled by us - we store handle the unformatted string I suppose instead of the formatted one? Which means we format it later when the object has changed in the meantime? I've never seen this occur with regular logging at least - but may be just me. |
We do, and pyblish does it too, and if it's logged to console, then it is formatted 3 times. Any additional handler is +1 formatting.
It does not happen in pyblish because we're handling it at 2 places. We do format the message at the time of emiting instead of using, so we get what was logged at the time of emit. |
Anyways, good start. We can discuss more, when we start to apply them to repositories. |
printf style is slowing stuff down because it is always evaluated even in the case the log isn't emitted after all. But that is the case for all formatting except the last mentioned, the extra |
In pyblish plugins are all logs emited, and are always formatted at the time of their emit. At least log handlers that are used by default (and it is not possible to avoid using them without rewriting pyblish). So, for pyblish logging it is actually faster to use f-string, because it is formatted only once. If we would use log formatting then it is formatted 1x + len(handlers) 100% (at least 2x in publisher tool). If we would not do it then we would get invalid logs: data = {}
self.log.info("%s", data)
data["key"] = "value"
self.log.info("%s", data)
>>> INFO: {'key': 'value'}
>>> INFO: {'key': 'value'} |
In that case we can add exception for pyblish plugins. Something like this could work:
|
Problem
Current ruff settings are to prohibitive.
We can reverse the logic, select all rules and just ignore those that we must. Here is the list of rules I had to disable in 3dequalizer addon for some reasons I'll try to explain here:
os.path
logic all over the place and rewriting it all to make use ofpathlib
would be major work.self
should be type annotated for the sake of older IDE that couldn't infer the type.cls
__init__()
to have that2|
in type annotations.__init__.py
to be almost in all directories with any python files even in a case where nothing will ever be imported from there.for docstrings ("D" rules) we should add
pydocstyle.convention = "google"
List[int] = [1, 2, 3]
vs.list[int] = [1, 2, 3]
foo: Union[int, str] = 1
vs.foo: int | str = 1
Some notes:
extra
argument in logging:Footnotes
This should be solved by
pydocstyle.convention = "google"
so no need to ignore ↩ ↩2 ↩3 ↩4Unless
mypy-init-return
is used in ruff config. ↩The text was updated successfully, but these errors were encountered: