Skip to content

Commit 3f26b08

Browse files
Restored Python 3.5 compatibility (#171)
* added Python 3.5 to Travis file * made type annotations in fileline compatible with Python 3.5 * Py 3.5 compatible annotations * fixed type annotation * fixed Python 3.6 type annotation * more Python 3.6 type annotation changes * fixed annotation in spectra module * fixed another annotation * fixed type annotation in server module * increased version * another server annotation
1 parent 21a0fa3 commit 3f26b08

File tree

8 files changed

+17
-16
lines changed

8 files changed

+17
-16
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ sudo: required
33
services:
44
- docker
55
python:
6+
- '3.5'
67
- '3.6'
78
install:
89
- pip install sphinx mypy

bugzoo/core/fileline.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def compactify(d: Dict['FileLine', Any]) -> Dict[str, Dict[int, Any]]:
1515
assert isinstance(d, dict)
1616
assert all(isinstance(x, FileLine) for x in d)
1717

18-
out: Dict[str, Dict[int, Any]] = {}
18+
out = {} # type: Dict[str, Dict[int, Any]]
1919
for (line, val) in d.items():
2020
if not line.filename in out:
2121
out[line.filename] = {}
@@ -24,7 +24,7 @@ def compactify(d: Dict['FileLine', Any]) -> Dict[str, Dict[int, Any]]:
2424

2525
@staticmethod
2626
def decompactify(d: Dict[str, Dict[int, Any]]) -> 'Dict[FileLine, Any]':
27-
lines: Dict['FileLine', Any] = {}
27+
lines = {} # type: Dict['FileLine', Any]
2828
for fn in d:
2929
for num in d[fn]:
3030
lines[FileLine(fn, num)] = d[fn][num]
@@ -82,16 +82,16 @@ def from_list(lst: List[FileLine]) -> 'FileLineSet':
8282

8383
@staticmethod
8484
def from_iter(itr: Iterable[FileLine]) -> 'FileLineSet':
85-
d: Dict[str, Set[int]] = {}
85+
d = {} # type: Dict[str, Set[int]]
8686
for line in itr:
8787
if not line.filename in d:
8888
d[line.filename] = set()
8989
d[line.filename].add(line.num)
9090
return FileLineSet(d)
9191

9292
def __init__(self, contents: Dict[str, Set[int]]) -> None:
93-
self.__contents: Dict[str, FrozenSet[int]] = \
94-
{fn: frozenset(line_nums) for (fn, line_nums) in contents.items()}
93+
self.__contents = \
94+
{fn: frozenset(line_nums) for (fn, line_nums) in contents.items()} # type: Dict[str, FrozenSet[int]]
9595

9696
def __iter__(self) -> Iterator[FileLine]:
9797
"""
@@ -172,7 +172,7 @@ def restricted_to_files(self, filenames: List[str]) -> 'FileLineSet':
172172
any one of the given files. (I.e., returns the intersection of this set
173173
and the set of all lines from a given set of files.)
174174
"""
175-
restricted: Dict[str, Set[int]] = {}
175+
restricted = {} # type: Dict[str, Set[int]]
176176
for fn in filenames:
177177
restricted[fn] = set(self.__contents[fn])
178178
return FileLineSet(restricted)

bugzoo/core/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _read_next(cls, lines: List[str]) -> 'Hunk':
7979
last_insertion_at = old_start_at
8080

8181

82-
hunk_lines: List[HunkLine] = []
82+
hunk_lines = [] # type: List[HunkLine]
8383
while True:
8484
# discarding the previous line ensures that we only consume lines
8585
# from the line buffer that belong to the hunk

bugzoo/core/spectra.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ class Spectra(object):
5959
def from_coverage(coverage: TestSuiteCoverage) -> 'Spectra':
6060
# tally the number of times that each line is touched by a passing
6161
# or failing test
62-
tally_failing: Dict[FileLine, int] = {}
63-
tally_passing: Dict[FileLine, int] = {}
62+
tally_failing = {} # type: Dict[FileLine, int]
63+
tally_passing = {} # type: Dict[FileLine, int]
6464

6565
for test in coverage.passing:
6666
for line in coverage[test].lines:

bugzoo/server/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from bugzoo.server.daemon import Daemon
55
from bugzoo.server.code import ErrorCode
66

7-
daemon: Daemon = None
7+
daemon = None # type: Daemon
88
app = flask.Flask(__name__)
99

1010

@@ -18,7 +18,7 @@ def list_bugs():
1818

1919
@app.route('/bugs/<uid>', methods=['GET'])
2020
def show_bug(uid: str):
21-
jsn: Dict[Any, Any] = {}
21+
jsn = {} # type: Dict[Any, Any]
2222
try:
2323
bug = daemon.bugs[uid]
2424
jsn = bug.to_dict()

bugzoo/testing/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ def from_dict(yml: dict) -> 'TestSuite':
113113
raise Exception("unexpected test harness type: {}".format(typ))
114114

115115
def __init__(self, tests: List[TestCase]) -> None:
116-
self.__tests: Dict[str, TestCase] = \
117-
{test.name: test for test in tests}
116+
self.__tests = \
117+
{test.name: test for test in tests} # type: Dict[str, TestCase]
118118

119119
def __getitem__(self, name: str) -> TestCase:
120120
"""

bugzoo/testing/simple.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ def __init__(self,
8787
super().__init__(command, context, time_limit, tests)
8888

8989
# extract the passing and failing test cases
90-
self.__passing: List[TestCase] = []
91-
self.__failing: List[TestCase] = []
90+
self.__passing = [] # type: List[TestCase]
91+
self.__failing = [] # type: List[TestCase]
9292

9393
for t in self.tests:
9494
if t.name.startswith('p'):

bugzoo/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.0.4'
1+
__version__ = '2.0.5'

0 commit comments

Comments
 (0)