Skip to content

Commit c87fb4d

Browse files
committed
Swift: remove now unused ql.Property.params
1 parent 9798d8b commit c87fb4d

File tree

4 files changed

+2
-32
lines changed

4 files changed

+2
-32
lines changed

swift/codegen/lib/ql.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
@dataclass
99
class Param:
1010
param: str
11-
type: str = None
1211
first: bool = False
1312

1413

@@ -19,16 +18,11 @@ class Property:
1918
tablename: str
2019
tableparams: List[Param]
2120
plural: str = None
22-
params: List[Param] = field(default_factory=list)
2321
first: bool = False
2422
local_var: str = "x"
2523
is_optional: bool = False
2624

2725
def __post_init__(self):
28-
if self.params:
29-
self.params[0].first = True
30-
while self.local_var in (p.param for p in self.params):
31-
self.local_var += "_"
3226
assert self.tableparams
3327
if self.type_is_class:
3428
self.tableparams = [x if x != "result" else self.local_var for x in self.tableparams]

swift/codegen/qlgen.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def get_ql_property(cls: schema.Class, prop: schema.Property):
2525
type=prop.type,
2626
tablename=inflection.tableize(f"{cls.name}_{prop.name}"),
2727
tableparams=["this", "index", "result"],
28-
params=[ql.Param("index", type="int")],
2928
is_optional=prop.is_optional,
3029
)
3130
elif prop.is_optional:
@@ -58,8 +57,6 @@ def get_types_used_by(cls: ql.Class):
5857
yield b
5958
for p in cls.properties:
6059
yield p.type
61-
for param in p.params:
62-
yield param.type
6360

6461

6562
def get_classes_used_by(cls: ql.Class):

swift/codegen/test/test_ql.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,11 @@
55
from swift.codegen.test.utils import *
66

77

8-
def test_property_has_first_param_marked():
9-
params = [ql.Param("a", "x"), ql.Param("b", "y"), ql.Param("c", "z")]
10-
expected = deepcopy(params)
11-
expected[0].first = True
12-
prop = ql.Property("Prop", "foo", "props", ["this"], params=params)
13-
assert prop.params == expected
14-
15-
168
def test_property_has_first_table_param_marked():
179
tableparams = ["a", "b", "c"]
1810
prop = ql.Property("Prop", "foo", "props", tableparams)
1911
assert prop.tableparams[0].first
2012
assert [p.param for p in prop.tableparams] == tableparams
21-
assert all(p.type is None for p in prop.tableparams)
22-
23-
24-
@pytest.mark.parametrize("params,expected_local_var", [
25-
(["a", "b", "c"], "x"),
26-
(["a", "x", "c"], "x_"),
27-
(["a", "x", "x_", "c"], "x__"),
28-
(["a", "x", "x_", "x__"], "x___"),
29-
])
30-
def test_property_local_var_avoids_params_collision(params, expected_local_var):
31-
prop = ql.Property("Prop", "foo", "props", ["this"], params=[ql.Param(p) for p in params])
32-
assert prop.local_var == expected_local_var
3313

3414

3515
def test_property_not_a_class():

swift/codegen/test/test_qlgen.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def run_mock():
1818
import_file = lambda: stub_path().with_suffix(".qll")
1919
stub_import_prefix = "stub.path."
2020
gen_import_prefix = "other.path."
21-
index_param = ql.Param("index", "int")
2221

2322

2423
def generate(opts, renderer, written=None):
@@ -121,7 +120,7 @@ def test_repeated_property(opts, input, renderer):
121120
import_file(): ql.ImportList([stub_import_prefix + "MyObject"]),
122121
stub_path() / "MyObject.qll": ql.Stub(name="MyObject", base_import=gen_import_prefix + "MyObject"),
123122
ql_output_path() / "MyObject.qll": ql.Class(name="MyObject", final=True, properties=[
124-
ql.Property(singular="Foo", plural="Foos", type="bar", tablename="my_object_foos", params=[index_param],
123+
ql.Property(singular="Foo", plural="Foos", type="bar", tablename="my_object_foos",
125124
tableparams=["this", "index", "result"]),
126125
])
127126
}
@@ -135,7 +134,7 @@ def test_repeated_optional_property(opts, input, renderer):
135134
import_file(): ql.ImportList([stub_import_prefix + "MyObject"]),
136135
stub_path() / "MyObject.qll": ql.Stub(name="MyObject", base_import=gen_import_prefix + "MyObject"),
137136
ql_output_path() / "MyObject.qll": ql.Class(name="MyObject", final=True, properties=[
138-
ql.Property(singular="Foo", plural="Foos", type="bar", tablename="my_object_foos", params=[index_param],
137+
ql.Property(singular="Foo", plural="Foos", type="bar", tablename="my_object_foos",
139138
tableparams=["this", "index", "result"], is_optional=True),
140139
])
141140
}

0 commit comments

Comments
 (0)