-
Notifications
You must be signed in to change notification settings - Fork 174
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
chore: add typing hints to pytest components #1478
base: master
Are you sure you want to change the base?
chore: add typing hints to pytest components #1478
Conversation
Add this logging level without changing Python’s internal logging module. This maintains architectural integrity and clarifies that the level is labgrid-specific. Signed-off-by: Rainer Poisel <[email protected]>
71233ce
to
b9f455c
Compare
Signed-off-by: Rainer Poisel <[email protected]>
Signed-off-by: Rainer Poisel <[email protected]>
Signed-off-by: Rainer Poisel <[email protected]>
…nents Signed-off-by: Rainer Poisel <[email protected]>
Signed-off-by: Rainer Poisel <[email protected]>
b9f455c
to
200d915
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message is missing the motivation for this change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, the message is:
Add this logging level without changing Python’s internal logging module. This maintains architectural integrity and clarifies that the level is labgrid-specific.
I initially found it unclear that the CONSOLE
debug level was specific to labgrid. By keeping it separate from Python's internal logging module, it’s immediately evident where this custom level is defined. This distinction is particularly helpful when using tools like pyright in my development environment. The ability to navigate directly to the definition within labgrid's logging module makes this even more clear.
Does this approach make sense to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I didn't even know that Labgrid had created its own debug level!
@@ -5,6 +5,7 @@ | |||
""" | |||
import os | |||
import warnings | |||
from typing import Dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Labgrid sort its imports?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the way ruff
sorts imports with the current configuration in this repo.
Would you prefer them to be in a different order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I suppose I just don't understand how the ordering works
Perhaps 'warnings' is consider an internal module and 'typing' is not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. Ruff puts from
imports after imports without the from
keyword.
"pytest_configure", | ||
"pytest_collection_modifyitems", | ||
"pytest_cmdline_main", | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be in a separate commit?
@@ -74,7 +80,8 @@ def env(request, record_testsuite_property): | |||
try: | |||
target = env.get_target(target_name) | |||
except UserError as e: | |||
pytest.exit(e) | |||
pytest.exit(str(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems to be unrelated to typing? Or does it fix a bug? If so, best to put the bug-fixes first, in one or more separate commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this fixes that the wrong type is passed to the pytest.exit()
function: pytest.exit.
def test_config(short_test): | ||
with pexpect.spawn(f'pytest --traceconfig {short_test}') as spawn: | ||
with pexpect.spawn(f"pytest --traceconfig {short_test}") as spawn: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Labgrid supposed to use " instead of ' ? I see both, I have been wondering
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I'll make sure these things remain untouched in this PR.
Personally, I'd prefer them to be consistent (whether it's '
or "
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I much prefer ' since it is easier to distinguish as small font sizes, but Labgrid seems to use both
@@ -17,6 +17,7 @@ more performant and the import times are shorter. | |||
New Features in 24.1 | |||
~~~~~~~~~~~~~~~~~~~~ | |||
- All components can be installed into the same virtualenv again. | |||
- The ``pytest`` specific parts of the labgrid framework now have typing hints. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pytest
-specific
Description
This PR introduces Python typing hints to the
pytest
specific components of the labgrid framework. These additions can be seen as initial steps towards enhancing the overall code navigation experience and improving the effectiveness of static code analysis tools.Checklist