Skip to content

Commit 034e437

Browse files
committed
[mypyc] Fix to work on 3.5.1
1 parent 3f73202 commit 034e437

File tree

8 files changed

+26
-26
lines changed

8 files changed

+26
-26
lines changed

mypyc/analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def cleanup_cfg(blocks: List[BasicBlock]) -> None:
127127

128128

129129
class AnalysisResult(Generic[T]):
130-
def __init__(self, before: AnalysisDict[T], after: AnalysisDict[T]) -> None:
130+
def __init__(self, before: 'AnalysisDict[T]', after: 'AnalysisDict[T]') -> None:
131131
self.before = before
132132
self.after = after
133133

mypyc/genops.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ def f(x: int) -> int:
1414
return r3
1515
"""
1616
from typing import (
17-
TypeVar, Callable, Dict, List, Tuple, Optional, Union, Sequence, Set, Any, cast, overload,
17+
TypeVar, Callable, Dict, List, Tuple, Optional, Union, Sequence, Set, Any, cast
1818
)
19-
MYPY = False
20-
if MYPY:
21-
from typing import ClassVar, NoReturn
19+
from typing_extensions import overload, ClassVar, NoReturn
2220
from abc import abstractmethod
2321
import sys
2422
import importlib.util

mypyc/lib-rt/CPy.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,8 @@ static PyObject *CPy_FormatTypeName(PyObject *value) {
10471047
return NULL;
10481048
}
10491049
/* This is quadratic but if that ever matters something is really weird. */
1050-
for (int i = 0; i < PyTuple_GET_SIZE(value); i++) {
1050+
int i;
1051+
for (i = 0; i < PyTuple_GET_SIZE(value); i++) {
10511052
PyObject *s = CPy_FormatTypeName(PyTuple_GET_ITEM(value, i));
10521053
if (!s) {
10531054
Py_DECREF(output);

mypyc/refcount.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def is_maybe_undefined(post_must_defined: Set[Value], src: Value) -> bool:
8080

8181

8282
def maybe_append_dec_ref(ops: List[Op], dest: Value,
83-
defined: AnalysisDict[Value], key: Tuple[BasicBlock, int]) -> None:
83+
defined: 'AnalysisDict[Value]', key: Tuple[BasicBlock, int]) -> None:
8484
if dest.type.is_refcounted:
8585
ops.append(DecRef(dest, is_xdec=is_maybe_undefined(defined[key], dest)))
8686

@@ -91,10 +91,10 @@ def maybe_append_inc_ref(ops: List[Op], dest: Value) -> None:
9191

9292

9393
def transform_block(block: BasicBlock,
94-
pre_live: AnalysisDict[Value],
95-
post_live: AnalysisDict[Value],
96-
pre_borrow: AnalysisDict[Value],
97-
post_must_defined: AnalysisDict[Value],
94+
pre_live: 'AnalysisDict[Value]',
95+
post_live: 'AnalysisDict[Value]',
96+
pre_borrow: 'AnalysisDict[Value]',
97+
post_must_defined: 'AnalysisDict[Value]',
9898
env: Environment) -> None:
9999
old_ops = block.ops
100100
ops = [] # type: List[Op]
@@ -139,10 +139,10 @@ def insert_branch_inc_and_decrefs(
139139
block: BasicBlock,
140140
cache: BlockCache,
141141
blocks: List[BasicBlock],
142-
pre_live: AnalysisDict[Value],
143-
pre_borrow: AnalysisDict[Value],
144-
post_borrow: AnalysisDict[Value],
145-
post_must_defined: AnalysisDict[Value],
142+
pre_live: 'AnalysisDict[Value]',
143+
pre_borrow: 'AnalysisDict[Value]',
144+
post_borrow: 'AnalysisDict[Value]',
145+
post_must_defined: 'AnalysisDict[Value]',
146146
env: Environment) -> None:
147147
"""Insert inc_refs and/or dec_refs after a branch/goto.
148148
@@ -196,7 +196,7 @@ def f(a: int) -> None
196196

197197

198198
def after_branch_decrefs(label: BasicBlock,
199-
pre_live: AnalysisDict[Value],
199+
pre_live: 'AnalysisDict[Value]',
200200
source_defined: Set[Value],
201201
source_borrowed: Set[Value],
202202
source_live_regs: Set[Value],
@@ -212,8 +212,8 @@ def after_branch_decrefs(label: BasicBlock,
212212

213213

214214
def after_branch_increfs(label: BasicBlock,
215-
pre_live: AnalysisDict[Value],
216-
pre_borrow: AnalysisDict[Value],
215+
pre_live: 'AnalysisDict[Value]',
216+
pre_borrow: 'AnalysisDict[Value]',
217217
source_borrowed: Set[Value],
218218
env: Environment) -> Tuple[Value, ...]:
219219
target_pre_live = pre_live[label, 0]

mypyc/test-data/run-multimodule.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class Bar:
401401
bar(self)
402402

403403
[file other.py]
404-
from typing import TYPE_CHECKING
404+
from typing_extensions import TYPE_CHECKING
405405
MYPY = False
406406
if MYPY:
407407
from native import Foo
@@ -431,7 +431,7 @@ def f(c: 'C') -> int:
431431
return c.x
432432

433433
[file other.py]
434-
from typing import TYPE_CHECKING
434+
from typing_extensions import TYPE_CHECKING
435435
if TYPE_CHECKING:
436436
from native import D
437437

mypyc/test-data/run.test

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3355,11 +3355,9 @@ internal_index_into()
33553355
2 * 3 + 1
33563356

33573357
[case testDummyTypes]
3358-
from typing import Tuple, List, Dict, NewType, NamedTuple
3359-
from mypy_extensions import TypedDict
3360-
MYPY = False
3361-
if MYPY:
3362-
from typing_extensions import Literal
3358+
from typing import Tuple, List, Dict, NamedTuple
3359+
from typing_extensions import Literal, TypedDict, NewType
3360+
33633361
class A:
33643362
pass
33653363

mypyc/uninit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def insert_uninit_checks(ir: FuncIR) -> None:
2828

2929
def split_blocks_at_uninits(env: Environment,
3030
blocks: List[BasicBlock],
31-
pre_must_defined: AnalysisDict[Value]) -> List[BasicBlock]:
31+
pre_must_defined: 'AnalysisDict[Value]') -> List[BasicBlock]:
3232
new_blocks = [] # type: List[BasicBlock]
3333

3434
# First split blocks on ops that may raise.

test-data/unit/lib-stub/typing_extensions.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from typing import TypeVar, Any, Mapping, Iterator, NoReturn, Dict, Type
2+
from typing import TYPE_CHECKING as TYPE_CHECKING
3+
from typing import NewType as NewType
4+
25
import sys
36

47
_T = TypeVar('_T')

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy