Skip to content

Commit 1e33b1a

Browse files
Sunnie912facebook-github-bot
authored andcommitted
Transform fbcode
Summary: This diff changes the struct initialization method from using positional arguments to keyword arguments, as indicated in the file title. Background: In thrift-python, user must use keyword arguments to initialize both mutable and immutable objects, meaning positional arguments are not allowed for this purpose. This behavior differs from py-deprecated, which permits both keyword and positional arguments for object initialization. To facilitate the migration from py-deprecated, we developed a tool that identifies all instances of struct initialization using positional arguments and converts them to keyword arguments. This will reduce the workload for users during the migration, and this diff is one of the outputs by using the tool. Reviewed By: dtolnay Differential Revision: D75805466 fbshipit-source-id: 9353c895247e849abf3dc1b95c27b36da1c696c4
1 parent 6d175c4 commit 1e33b1a

7 files changed

Lines changed: 187 additions & 146 deletions

File tree

eden/integration/debug_test.py

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ def assert_blob_not_available(
7272
) -> None:
7373
response = client.debugGetBlob(
7474
DebugGetScmBlobRequest(
75-
MountId(self.mount.encode()),
76-
blob_id,
77-
origin,
75+
mountId=MountId(mountPoint=self.mount.encode()),
76+
id=blob_id,
77+
origins=origin,
7878
)
7979
)
8080
print(response)
@@ -90,15 +90,15 @@ def assert_blob_available(
9090
) -> None:
9191
response = client.debugGetBlob(
9292
DebugGetScmBlobRequest(
93-
MountId(self.mount.encode()),
94-
blob_id,
95-
origin,
93+
mountId=MountId(mountPoint=self.mount.encode()),
94+
id=blob_id,
95+
origins=origin,
9696
)
9797
)
9898
print(response)
9999
self.assertEqual(
100100
DebugGetScmBlobResponse(
101-
[ScmBlobWithOrigin(blob=ScmBlobOrError(blob=data), origin=origin)]
101+
blobs=[ScmBlobWithOrigin(blob=ScmBlobOrError(blob=data), origin=origin)]
102102
),
103103
response,
104104
)
@@ -157,9 +157,9 @@ def test_debug_blob_locations(self) -> None:
157157
# check a request from multiple places:
158158
response = client.debugGetBlob(
159159
DebugGetScmBlobRequest(
160-
MountId(self.mount.encode()),
161-
file.hash,
162-
DataFetchOrigin.MEMORY_CACHE
160+
mountId=MountId(mountPoint=self.mount.encode()),
161+
id=file.hash,
162+
origins=DataFetchOrigin.MEMORY_CACHE
163163
| DataFetchOrigin.DISK_CACHE
164164
| DataFetchOrigin.LOCAL_BACKING_STORE
165165
| DataFetchOrigin.REMOTE_BACKING_STORE
@@ -206,9 +206,9 @@ def assert_metadata_not_available(
206206
) -> None:
207207
response = client.debugGetBlobMetadata(
208208
DebugGetBlobMetadataRequest(
209-
MountId(self.mount.encode()),
210-
blob_id,
211-
origin,
209+
mountId=MountId(mountPoint=self.mount.encode()),
210+
id=blob_id,
211+
origins=origin,
212212
)
213213
)
214214
print(response)
@@ -225,15 +225,15 @@ def assert_metadata_available(
225225
) -> None:
226226
response = client.debugGetBlobMetadata(
227227
DebugGetBlobMetadataRequest(
228-
MountId(self.mount.encode()),
229-
blob_id,
230-
origin,
228+
mountId=MountId(mountPoint=self.mount.encode()),
229+
id=blob_id,
230+
origins=origin,
231231
)
232232
)
233233
print(response)
234234
self.assertEqual(
235235
DebugGetBlobMetadataResponse(
236-
[
236+
metadatas=[
237237
BlobMetadataWithOrigin(
238238
metadata=BlobMetadataOrError(
239239
metadata=ScmBlobMetadata(size=size, contentsSha1=sha1)
@@ -303,9 +303,9 @@ def test_debug_blob_metadata_locations(self) -> None:
303303
# check a request from multiple places:
304304
response = client.debugGetBlobMetadata(
305305
DebugGetBlobMetadataRequest(
306-
MountId(self.mount.encode()),
307-
file.hash,
308-
DataFetchOrigin.MEMORY_CACHE
306+
mountId=MountId(mountPoint=self.mount.encode()),
307+
id=file.hash,
308+
origins=DataFetchOrigin.MEMORY_CACHE
309309
| DataFetchOrigin.DISK_CACHE
310310
| DataFetchOrigin.LOCAL_BACKING_STORE
311311
| DataFetchOrigin.REMOTE_BACKING_STORE
@@ -339,9 +339,9 @@ def assert_tree_not_available(
339339
) -> None:
340340
response = client.debugGetTree(
341341
DebugGetScmTreeRequest(
342-
MountId(self.mount.encode()),
343-
tree_id,
344-
origin,
342+
mountId=MountId(mountPoint=self.mount.encode()),
343+
id=tree_id,
344+
origins=origin,
345345
)
346346
)
347347
print(response)
@@ -359,18 +359,20 @@ def assert_tree_available(
359359
) -> None:
360360
response = client.debugGetTree(
361361
DebugGetScmTreeRequest(
362-
MountId(self.mount.encode()),
363-
tree_id,
364-
origin,
362+
mountId=MountId(mountPoint=self.mount.encode()),
363+
id=tree_id,
364+
origins=origin,
365365
)
366366
)
367367
print(f"response of debugGetTree: {response}")
368368
self.assertEqual(
369369
DebugGetScmTreeResponse(
370-
[
370+
trees=[
371371
ScmTreeWithOrigin(
372372
scmTreeData=ScmTreeOrError(
373-
[ScmTreeEntry(name=name, mode=mode, id=thrift_obj_id)]
373+
treeEntries=[
374+
ScmTreeEntry(name=name, mode=mode, id=thrift_obj_id)
375+
]
374376
),
375377
origin=origin,
376378
)
@@ -455,9 +457,9 @@ def test_debug_tree_locations(self) -> None:
455457
# check a request from multiple places:
456458
response = client.debugGetTree(
457459
DebugGetScmTreeRequest(
458-
MountId(self.mount.encode()),
459-
treeInfo.treeHash,
460-
DataFetchOrigin.MEMORY_CACHE
460+
mountId=MountId(mountPoint=self.mount.encode()),
461+
id=treeInfo.treeHash,
462+
origins=DataFetchOrigin.MEMORY_CACHE
461463
| DataFetchOrigin.DISK_CACHE
462464
| DataFetchOrigin.LOCAL_BACKING_STORE
463465
| DataFetchOrigin.REMOTE_BACKING_STORE
@@ -483,7 +485,7 @@ def test_debug_tree_locations(self) -> None:
483485
else:
484486
self.assertEqual(
485487
ScmTreeOrError(
486-
[
488+
treeEntries=[
487489
ScmTreeEntry(
488490
name=treeEntry.name,
489491
mode=treeEntry.mode | 0o644,

eden/integration/glob_test.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ def assert_glob_with_dtypes(
120120
msg: Optional[str] = None,
121121
) -> None:
122122
params = GlobParams(
123-
self.mount_path_bytes,
124-
globs,
123+
mountPoint=self.mount_path_bytes,
124+
globs=globs,
125125
includeDotfiles=include_dotfiles,
126126
wantDtype=True,
127127
)
@@ -418,14 +418,23 @@ def test_malformed_query(self) -> None:
418418
self.assertEqual(EdenErrorType.POSIX_ERROR, ctx.exception.errorType)
419419

420420
with self.assertRaises(EdenError) as ctx:
421-
self.client.globFiles(GlobParams(self.mount_path_bytes, ["adir["], True))
421+
self.client.globFiles(
422+
GlobParams(
423+
mountPoint=self.mount_path_bytes,
424+
globs=["adir["],
425+
includeDotfiles=True,
426+
)
427+
)
422428
self.assertIn("unterminated bracket sequence", str(ctx.exception))
423429
self.assertEqual(EdenErrorType.POSIX_ERROR, ctx.exception.errorType)
424430

425431
def test_globs_may_not_include_dotdot(self) -> None:
426432
with self.assertRaises(EdenError) as ctx:
427433
self.client.globFiles(
428-
GlobParams(self.mount_path_bytes, ["java/../java/com/**/*.java"])
434+
GlobParams(
435+
mountPoint=self.mount_path_bytes,
436+
globs=["java/../java/com/**/*.java"],
437+
)
429438
)
430439
self.assertEqual(
431440
"Invalid glob (PathComponent must not be ..): java/../java/com/**/*.java",
@@ -482,22 +491,29 @@ def test_recursive_wildcard_suffix_with_dotfile(self) -> None:
482491
def test_malformed_query(self) -> None:
483492
with self.assertRaises(EdenError) as ctx:
484493
self.client.prefetchFilesV2(
485-
PrefetchParams(self.mount_path_bytes, globs=["adir["])
494+
PrefetchParams(mountPoint=self.mount_path_bytes, globs=["adir["])
486495
)
487496
self.assertIn("unterminated bracket sequence", str(ctx.exception))
488497
self.assertEqual(EdenErrorType.POSIX_ERROR, ctx.exception.errorType)
489498

490499
with self.assertRaises(EdenError) as ctx:
491500
self.client.prefetchFilesV2(
492-
PrefetchParams(self.mount_path_bytes, ["adir["], True)
501+
PrefetchParams(
502+
mountPoint=self.mount_path_bytes,
503+
globs=["adir["],
504+
directoriesOnly=True,
505+
)
493506
)
494507
self.assertIn("unterminated bracket sequence", str(ctx.exception))
495508
self.assertEqual(EdenErrorType.POSIX_ERROR, ctx.exception.errorType)
496509

497510
def test_globs_may_not_include_dotdot(self) -> None:
498511
with self.assertRaises(EdenError) as ctx:
499512
self.client.prefetchFilesV2(
500-
PrefetchParams(self.mount_path_bytes, ["java/../java/com/**/*.java"])
513+
PrefetchParams(
514+
mountPoint=self.mount_path_bytes,
515+
globs=["java/../java/com/**/*.java"],
516+
)
501517
)
502518
self.assertEqual(
503519
"Invalid glob (PathComponent must not be ..): java/../java/com/**/*.java",

eden/integration/prjfs_match_fs.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def match_fs(self, files: List[bytes]) -> None:
4545
with self.eden.get_thrift_client_legacy() as client:
4646
errors = client.matchFilesystem(
4747
MatchFileSystemRequest(
48-
MountId(self.mount.encode()),
49-
files,
48+
mountPoint=MountId(mountPoint=self.mount.encode()), paths=files
5049
)
5150
)
5251
for error in errors.results:
@@ -143,8 +142,8 @@ def test_fix_failed(self) -> None:
143142
)
144143
errors = client.matchFilesystem(
145144
MatchFileSystemRequest(
146-
MountId(self.mount.encode()),
147-
[b"adir/file"],
145+
mountPoint=MountId(mountPoint=self.mount.encode()),
146+
paths=[b"adir/file"],
148147
)
149148
)
150149
print(errors)

0 commit comments

Comments
 (0)