From 4698564950363f70358f60de81ff8c1f9509345c Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Wed, 14 Jan 2026 12:29:16 +0000 Subject: [PATCH] pstore: fixes types, treat it as a collection this adds hash-like typing to signal its key-value store semantics. it seems like a breaking change, but in practice this has been broken for a while. Other wrong sigs were fixed, such as transaction, which requires a block. --- stdlib/pstore/0/pstore.rbs | 65 ++++++++++++++++++++------------------ stdlib/psych/0/store.rbs | 6 ++-- test/stdlib/PStore_test.rb | 27 ++++++++++++++-- 3 files changed, 62 insertions(+), 36 deletions(-) diff --git a/stdlib/pstore/0/pstore.rbs b/stdlib/pstore/0/pstore.rbs index eddd0862a..922c6ad8b 100644 --- a/stdlib/pstore/0/pstore.rbs +++ b/stdlib/pstore/0/pstore.rbs @@ -299,7 +299,7 @@ # end # end # -class PStore +class PStore[unchecked out K, unchecked out V] # # - def root?: (untyped name) -> bool + def key?: (K name) -> bool + + alias root? key? # # - def roots: () -> Array[untyped] + def keys: () -> Array[K] + + alias roots keys # # Whether PStore should do its best to prevent file corruptions, even when an @@ -458,7 +462,7 @@ class PStore # raises no unexpected I/O error; if such an error occurs during a write to # the store, the file may become corrupted. # - def ultra_safe: () -> untyped + def ultra_safe: () -> bool # # Whether PStore should do its best to prevent file corruptions, even when an @@ -475,7 +479,7 @@ class PStore # raises no unexpected I/O error; if such an error occurs during a write to # the store, the file may become corrupted. # - def ultra_safe=: (untyped) -> untyped + def ultra_safe=: (bool) -> bool private @@ -486,14 +490,14 @@ class PStore # - empty_marshal_checksum() # --> # - def empty_marshal_checksum: () -> untyped + def empty_marshal_checksum: () -> String # # - def empty_marshal_data: () -> untyped + def empty_marshal_data: () -> String # # Raises PStore::Error if the calling code is not in a PStore#transaction. # - def in_transaction: () -> untyped + def in_transaction: () -> void # # - def save_data_with_atomic_file_rename_strategy: (untyped data, untyped file) -> untyped + def save_data_with_atomic_file_rename_strategy: (string data, File file) -> void # # - def save_data_with_fast_strategy: (untyped data, untyped file) -> untyped -end + def save_data_with_fast_strategy: (string data, File file) -> void -PStore::EMPTY_MARSHAL_CHECKSUM: String + EMPTY_MARSHAL_CHECKSUM: String -PStore::EMPTY_MARSHAL_DATA: String + EMPTY_MARSHAL_DATA: String -PStore::EMPTY_STRING: String + EMPTY_STRING: String -PStore::RDWR_ACCESS: Hash[untyped, untyped] + RDWR_ACCESS: { mode: Integer, encoding: Encoding } -PStore::RD_ACCESS: Hash[untyped, untyped] + RD_ACCESS: { mode: Integer, encoding: Encoding } -PStore::VERSION: String + VERSION: String -PStore::WR_ACCESS: Hash[untyped, untyped] + WR_ACCESS: { mode: Integer, encoding: Encoding } +end diff --git a/stdlib/psych/0/store.rbs b/stdlib/psych/0/store.rbs index 687d8b590..b4f1b1931 100644 --- a/stdlib/psych/0/store.rbs +++ b/stdlib/psych/0/store.rbs @@ -30,7 +30,7 @@ # greeting: # hello: world # -class Psych::Store < ::PStore +class Psych::Store < ::PStore[string, untyped] #