Skip to content

Conversation

cclauss
Copy link
Collaborator

@cclauss cclauss commented Apr 13, 2018

Python 3 has more restrictive scoping rules that Python 2 so a variable created inside of a list comprehension is not available outside of that list comprehension.

flake8 testing of https://github.com/ggtracker/sc2reader on Python 3.6.3

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

./sc2reader/scripts/sc2parse.py:48:25: F821 undefined name 'human'
                        human.pids = set([human.pid for human in replay.humans])
                        ^
./sc2reader/scripts/sc2parse.py:52:28: F821 undefined name 'human'
                        if human.pids != event_pids:
                           ^
./sc2reader/scripts/sc2parse.py:53:109: F821 undefined name 'human'
                            print('Event Pid problem!  pids={pids} but event pids={event_pids}'.format(pids=human.pids, event_pids=event_pids))
                                                                                                            ^
3     F821 undefined name 'human'
3

This PR creates a new human_pids to hold the set of all replay.humans.pids instead of modifying the pid of the last human in that list.

Python 3 has more restrictive scoping rules that Python 2 so a variable created inside of a list comprehension is not available outside of that list comprehension.

flake8 testing of https://github.com/ggtracker/sc2reader on Python 3.6.3 

$ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__
```
./sc2reader/scripts/sc2parse.py:48:25: F821 undefined name 'human'
                        human.pids = set([human.pid for human in replay.humans])
                        ^
./sc2reader/scripts/sc2parse.py:52:28: F821 undefined name 'human'
                        if human.pids != event_pids:
                           ^
./sc2reader/scripts/sc2parse.py:53:109: F821 undefined name 'human'
                            print('Event Pid problem!  pids={pids} but event pids={event_pids}'.format(pids=human.pids, event_pids=event_pids))
                                                                                                            ^
3     F821 undefined name 'human'
3
```
This PR creates a new __human_pids__ to hold the set of all __replay.humans.pids__ instead of modifying the pid of the last human in that list.
@cclauss
Copy link
Collaborator Author

cclauss commented Apr 13, 2018

These fixes are also incorporated in #47

@StoicLoofah
Copy link
Collaborator

Since these changes are in #47, can we close this PR now?

@cclauss cclauss closed this Apr 15, 2018
@cclauss cclauss deleted the patch-2 branch April 15, 2018 22:12
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