Skip to content

Commit 6c40db7

Browse files
shannonzhufacebook-github-bot
authored andcommitted
Remove leading underscore in __test_sink, __test_source, etc.
Summary: The naming convention for these test functions will break if we start handling private names correctly in classes, see docs on private name mangling: https://docs.python.org/3/reference/expressions.html?highlight=mangling At runtime, it's impossible to access a function named with a leading double underscore from inside a class: ``` >>> def __toplevel(x: int) -> int: ... return x ... >>> class Foo: ... def test(self): ... print(__toplevel(1)) ... >>> Foo().test() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in test NameError: name '_Foo__toplevel' is not defined ``` This diff is a no-op except adjusting the naming of these test helpers to lead with a single underscore instead. Includes: `__test_sink`, `__test_source` still need to do: `__global_sink`, `__user_controlled`, `__tito` Reviewed By: gbleaney Differential Revision: D30150334 fbshipit-source-id: 271814d20ef9df6984531bffe8158151cfd91574
1 parent 0852005 commit 6c40db7

File tree

196 files changed

+3290
-3290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+3290
-3290
lines changed

source/analysis/test/globalResolutionTest.ml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,7 +2502,7 @@ let test_define context =
25022502
in
25032503
let source =
25042504
{|
2505-
from builtins import __test_sink
2505+
from builtins import _test_sink
25062506
from typing import Callable
25072507

25082508
def simple_function(x: int) -> str:
@@ -2512,14 +2512,14 @@ let test_define context =
25122512
def with_logging(callable: Callable[[str], None]) -> Callable[[str], None]:
25132513

25142514
def inner(y: str) -> None:
2515-
__test_sink(y)
2515+
_test_sink(y)
25162516
callable(y)
25172517

25182518
return inner
25192519

25202520
def two_inner_functions(callable: Callable[[str], None]) -> Callable[[str], None]:
25212521
def inner1(y: str) -> None:
2522-
__test_sink(y)
2522+
_test_sink(y)
25232523

25242524
def inner2(y: str) -> None:
25252525
inner1(y)
@@ -2530,7 +2530,7 @@ let test_define context =
25302530
def decorator_factory(x: int) -> Callable[[Callable[[str], None]], Callable[[str], None]]:
25312531
def wrapper(f: Callable[[str], None]) -> Callable[[str], None]:
25322532
def inner(y: str) -> None:
2533-
__test_sink(y)
2533+
_test_sink(y)
25342534
f(y)
25352535

25362536
return inner
@@ -2554,12 +2554,12 @@ let test_define context =
25542554
~source
25552555
~expected_define_source:
25562556
{|
2557-
from builtins import __test_sink
2557+
from builtins import _test_sink
25582558
from typing import Callable
25592559
def with_logging(callable: Callable[[str], None]) -> Callable[[str], None]:
25602560

25612561
def inner(y: str) -> None:
2562-
__test_sink(y)
2562+
_test_sink(y)
25632563
callable(y)
25642564

25652565
return inner
@@ -2569,12 +2569,12 @@ let test_define context =
25692569
~source
25702570
~expected_define_source:
25712571
{|
2572-
from builtins import __test_sink
2572+
from builtins import _test_sink
25732573
from typing import Callable
25742574

25752575
def two_inner_functions(callable: Callable[[str], None]) -> Callable[[str], None]:
25762576
def inner1(y: str) -> None:
2577-
__test_sink(y)
2577+
_test_sink(y)
25782578

25792579
def inner2(y: str) -> None:
25802580
inner1(y)
@@ -2587,13 +2587,13 @@ let test_define context =
25872587
~source
25882588
~expected_define_source:
25892589
{|
2590-
from builtins import __test_sink
2590+
from builtins import _test_sink
25912591
from typing import Callable
25922592

25932593
def decorator_factory(x: int) -> Callable[[Callable[[str], None]], Callable[[str], None]]:
25942594
def wrapper(f: Callable[[str], None]) -> Callable[[str], None]:
25952595
def inner(y: str) -> None:
2596-
__test_sink(y)
2596+
_test_sink(y)
25972597
f(y)
25982598

25992599
return inner

0 commit comments

Comments
 (0)