1
- # typed: strict
1
+ # typed: false
2
2
# frozen_string_literal: true
3
3
4
- require "sorbet-runtime"
5
4
require "json"
6
5
7
- begin
8
- T ::Configuration . default_checked_level = :never
9
- # Suppresses call validation errors
10
- T ::Configuration . call_validation_error_handler = -> ( *) { }
11
- # Suppresses errors caused by T.cast, T.let, T.must, etc.
12
- T ::Configuration . inline_type_error_handler = -> ( *) { }
13
- # Suppresses errors caused by incorrect parameter ordering
14
- T ::Configuration . sig_validation_error_handler = -> ( *) { }
15
- rescue
16
- # Need this rescue so that if another gem has
17
- # already set the checked level by the time we
18
- # get to it, we don't fail outright.
19
- nil
20
- end
21
-
22
6
# NOTE: We should avoid printing to stderr since it causes problems. We never read the standard error pipe from the
23
7
# client, so it will become full and eventually hang or crash. Instead, return a response with an `error` key.
24
8
@@ -27,16 +11,12 @@ module Rails
27
11
class Server
28
12
VOID = Object . new
29
13
30
- extend T ::Sig
31
-
32
- sig { void }
33
14
def initialize
34
15
$stdin. sync = true
35
16
$stdout. sync = true
36
- @running = T . let ( true , T :: Boolean )
17
+ @running = true
37
18
end
38
19
39
- sig { void }
40
20
def start
41
21
initialize_result = { result : { message : "ok" } } . to_json
42
22
$stdout. write ( "Content-Length: #{ initialize_result . length } \r \n \r \n #{ initialize_result } " )
@@ -54,19 +34,13 @@ def start
54
34
end
55
35
end
56
36
57
- sig do
58
- params (
59
- request : String ,
60
- params : T . nilable ( T ::Hash [ Symbol , T . untyped ] ) ,
61
- ) . returns ( T . any ( Object , T ::Hash [ Symbol , T . untyped ] ) )
62
- end
63
37
def execute ( request , params )
64
38
case request
65
39
when "shutdown"
66
40
@running = false
67
41
VOID
68
42
when "model"
69
- resolve_database_info_from_model ( T . must ( params ) . fetch ( :name ) )
43
+ resolve_database_info_from_model ( params . fetch ( :name ) )
70
44
when "reload"
71
45
::Rails . application . reloader . reload!
72
46
VOID
@@ -79,7 +53,6 @@ def execute(request, params)
79
53
80
54
private
81
55
82
- sig { params ( model_name : String ) . returns ( T ::Hash [ Symbol , T . untyped ] ) }
83
56
def resolve_database_info_from_model ( model_name )
84
57
const = ActiveSupport ::Inflector . safe_constantize ( model_name )
85
58
unless active_record_model? ( const )
@@ -105,7 +78,6 @@ def resolve_database_info_from_model(model_name)
105
78
{ error : e . full_message ( highlight : false ) }
106
79
end
107
80
108
- sig { params ( const : T . untyped ) . returns ( T ::Boolean ) }
109
81
def active_record_model? ( const )
110
82
!!(
111
83
const &&
0 commit comments