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

stbt lint: Add checker stbt-frame-object-property-single-frame #581

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

drothlis
Copy link
Contributor

@drothlis drothlis commented Mar 27, 2019

FrameObject properties must process a single frame; functions like "stbt.wait_for_match" retrieve additional frames from the device-under-test.

Suggested during code review of #580.

TODO:

  • Figure out why pylint is reporting Undefined variable 'wait_for_match' (see comment).

@drothlis
Copy link
Contributor Author

drothlis commented Mar 27, 2019

The failure in test_that_stbt_lint_checks_frameobjects is bizarre:

--- lint.expected	2019-03-27 14:10:52.536094182 +0000
+++ /dev/fd/63	2019-03-27 14:10:52.536094182 +0000
@@ -11,3 +11,4 @@
 E: 34,38: FrameObject properties must use "self._frame", not "get_frame()" (stbt-frame-object-get-frame)
 E: 36,32: FrameObject properties must use "self._frame", not "get_frame()" (stbt-frame-object-get-frame)
 E: 40,15: FrameObject properties must not use "wait_for_match" (stbt-frame-object-property-single-frame)
+E: 40,15: Undefined variable 'wait_for_match' (undefined-variable)

If I remove the new checker, pylint doesn't report undefined-variable. The line in question is:

@property
def another2(self):
return stbt.wait_for_match("videotestsrc-redblue.png")

@drothlis drothlis force-pushed the lint-frameobject-single-frame branch 2 times, most recently from eb2ad91 to bdf74d6 Compare March 27, 2019 14:44
@drothlis drothlis force-pushed the lint-frameobject-single-frame branch from bdf74d6 to a633b2f Compare June 14, 2022 10:03
@drothlis
Copy link
Contributor Author

drothlis commented Jun 14, 2022

Rebased onto main. The test failure is still happening with Ubuntu 22.04's version of pylint:

pylint 2.12.2
astroid 2.9.3
Python 3.10.4 (main, Apr  2 2022, 09:04:19) [GCC 11.2.0]

This is the line in the test-case:

@property
def another2(self):
return stbt.wait_for_match("videotestsrc-redblue.png")

And this is the pylint output:

E: 40,15: FrameObject properties must not use "wait_for_match" (stbt-frame-object-property-single-frame)
E: 40,15: Undefined variable 'wait_for_match' (undefined-variable)

The first line is expected, the 2nd line isn't.

If I comment out this line, pylint doesn't show either message:

self.add_message('E7010', node=node, args=node.func.as_string())

FrameObject properties must process a single frame; functions like
"stbt.wait_for_match" retrieve additional frames from the
device-under-test.
@drothlis drothlis force-pushed the lint-frameobject-single-frame branch from a633b2f to 8d37b0d Compare July 8, 2022 07:45
@drothlis
Copy link
Contributor Author

drothlis commented Jul 8, 2022

Rebased onto main to get #762. The bug is still happening (pylint 2.14.3, astroid 2.11.6).

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.

None yet

1 participant