Skip to content

Conversation

@cclauss
Copy link

@cclauss cclauss commented Feb 1, 2018

StateSamplerInfo definition copied from https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/worker/statesampler.py#L32-L34

flake8 testing of https://github.com/apache/beam

$ flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

./sdks/python/apache_beam/runners/worker/statesampler_slow.py:54:12: F821 undefined name 'StateSamplerInfo'
    return StateSamplerInfo(
           ^

@cclauss cclauss changed the title Define StateSamplerInfo for line 58 Fix undefined name: StateSamplerInfo on line 58 Feb 1, 2018
@robertwb
Copy link
Contributor

robertwb commented Feb 1, 2018

Perhaps this merits adding a test as well?

@cclauss
Copy link
Author

cclauss commented Feb 7, 2018

#4610 is the test for finding regressions on this fix.

@jkff jkff requested a review from robertwb February 7, 2018 22:14
@cclauss cclauss force-pushed the patch-3 branch 2 times, most recently from 1534233 to 72bfa62 Compare March 2, 2018 09:25
cclauss pushed a commit to cclauss/beam that referenced this pull request Mar 5, 2018
My sense is that __E901,E999,F821,F822,F823__ are the "showstopper" flake8 issues that can halt the runtime with a SyntaxError, NameError, etc. The other flake8 issues are merely "style violations" -- useful for readability but they do not effect runtime safety.

I would therefore suggest replacing __--select=E999__ with __--select=E901,E999,F822,F823__ because the codebase currently passes all of these tests and we would like to avoid any backsliding. We would also want to add __F821__ (undefined names!) to that list but work must be completed on basestring, buffer(), cmp(), file(), unicode, xrange(), and apache#4561 before that can be done.

* F821: undefined name `name`
* F822: undefined name `name` in `__all__`
* F823: local variable `name` referenced before assignment
* E901: SyntaxError or IndentationError
* E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree
@robertwb
Copy link
Contributor

robertwb commented Mar 7, 2018

Though this is only a small amount of code, it seems odd to duplicate it. Is there a better common location to put it?

@cclauss cclauss force-pushed the patch-3 branch 2 times, most recently from 1d5acbd to 48b1a9e Compare March 17, 2018 09:36
@cclauss
Copy link
Author

cclauss commented Mar 17, 2018

Remove duplicate definition and switch to from apache_beam.runners.worker.statesampler import StateSamplerInfo.

__StateSamplerInfo__ definition copied from https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/worker/statesampler.py#L32-L34

flake8 testing of https://github.com/apache/beam

$ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__
```
./sdks/python/apache_beam/runners/worker/statesampler_slow.py:54:12: F821 undefined name 'StateSamplerInfo'
    return StateSamplerInfo(
           ^
```
@cclauss
Copy link
Author

cclauss commented Mar 19, 2018

@robertwb Is this the solution you were looking for?

@robertwb
Copy link
Contributor

Resolved merge conflicts.

Jenkins: retest this please.

@cclauss
Copy link
Author

cclauss commented Apr 26, 2018

No longer required.

@cclauss cclauss closed this Apr 26, 2018
@cclauss cclauss deleted the patch-3 branch April 26, 2018 11:59
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.

2 participants