Skip to content

Commit

Permalink
DEBUG-2334 upgrade steep & rbs (#3950)
Browse files Browse the repository at this point in the history
* DEBUG-2334 upgrade steep & rbs

* return appsec settings to correct type signature and exclude the file from steep

---------

Co-authored-by: Oleg Pudeyev <code@olegp.name>
  • Loading branch information
p-datadog and p committed Sep 25, 2024
1 parent 2209a7c commit a6b9175
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ end

group :check do
if RUBY_VERSION >= '3.0.0' && RUBY_PLATFORM != 'java'
gem 'rbs', '~> 3.2.0', require: false
gem 'steep', '~> 1.6.0', require: false
gem 'rbs', '~> 3.5.0', require: false
gem 'steep', '~> 1.7.0', require: false
end
gem 'ruby_memcheck', '>= 3' if RUBY_VERSION >= '3.4.0' && RUBY_PLATFORM != 'java'
gem 'standard', require: false
Expand Down
4 changes: 4 additions & 0 deletions Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ target :datadog do

ignore 'lib/datadog/appsec.rb'
ignore 'lib/datadog/appsec/component.rb'
# Excluded due to https://github.com/soutaro/steep/issues/1232
ignore 'lib/datadog/appsec/configuration/settings.rb'
ignore 'lib/datadog/appsec/contrib/'
ignore 'lib/datadog/appsec/contrib/auto_instrument.rb'
ignore 'lib/datadog/appsec/contrib/integration.rb'
Expand Down Expand Up @@ -69,6 +71,8 @@ target :datadog do
ignore 'lib/datadog/core/metrics/options.rb'
ignore 'lib/datadog/core/pin.rb'
ignore 'lib/datadog/core/rate_limiter.rb'
# steep fails in this file due to https://github.com/soutaro/steep/issues/1231
ignore 'lib/datadog/core/remote/tie.rb'
ignore 'lib/datadog/core/runtime/ext.rb'
ignore 'lib/datadog/core/runtime/metrics.rb'
ignore 'lib/datadog/core/transport/ext.rb'
Expand Down
10 changes: 5 additions & 5 deletions lib/datadog/core/environment/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def development?
# 2. Checking if `Net::HTTP` is referring to the original one
# => ::Net::HTTP.equal?(::WebMock::HttpLibAdapters::NetHttpAdapter::OriginalNetHTTP)
def webmock_enabled?
defined?(::WebMock::HttpLibAdapters::NetHttpAdapter) &&
!!(defined?(::WebMock::HttpLibAdapters::NetHttpAdapter) &&
defined?(::Net::HTTP) &&
::Net::HTTP.equal?(::WebMock::HttpLibAdapters::NetHttpAdapter.instance_variable_get(:@webMockNetHTTP))
::Net::HTTP.equal?(::WebMock::HttpLibAdapters::NetHttpAdapter.instance_variable_get(:@webMockNetHTTP)))
end

private
Expand Down Expand Up @@ -68,7 +68,7 @@ def minitest?

# Check if we are running from `bin/cucumber` or `cucumber/rake/task`.
def cucumber?
defined?(::Cucumber::Cli)
!!defined?(::Cucumber::Cli)
end

# If this is a Rails application, use different heuristics to detect
Expand All @@ -80,7 +80,7 @@ def rails_development?
# detecting its presence is enough to deduct if this is a development environment.
#
# @see https://github.com/rails/spring/blob/48b299348ace2188444489a0c216a6f3e9687281/README.md?plain=1#L204-L207
defined?(::Spring) || rails_env_development?
!!defined?(::Spring) || rails_env_development?
end

RAILS_ENV_DEVELOPMENT = Set['development', 'test'].freeze
Expand All @@ -94,7 +94,7 @@ def rails_development?
# it's common to have a custom "staging" environment, and such environment normally want to run as close
# to production as possible.
def rails_env_development?
defined?(::Rails.env) && RAILS_ENV_DEVELOPMENT.include?(::Rails.env)
!!defined?(::Rails.env) && RAILS_ENV_DEVELOPMENT.include?(::Rails.env)
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/datadog/core/remote/tie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def self.boot
barrier = Datadog::Core::Remote.active_remote.barrier(:once)
end

# steep does not permit the next line due to
# https://github.com/soutaro/steep/issues/1231
Boot.new(barrier, t)
end
end
Expand Down
4 changes: 2 additions & 2 deletions sig/datadog/core/remote/tie.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ module Datadog
module Core
module Remote
module Tie
class Boot < ::Struct[untyped]
class Boot < ::Struct[[Component::Barrier, Numeric]]
def initialize: (Component::Barrier? barrier, Numeric? time) -> void

attr_reader barrier: Component::Barrier
attr_reader time: Numeric
end

def self.boot: () -> (nil | Boot)
def self.boot: () -> Boot?
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion sig/datadog/core/telemetry/event.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module Datadog

def agent_transport: (untyped config) -> String

def conf_value: (String name, Object value, Integer seq_id, ?String origin) -> Hash[Symbol, untyped]
def conf_value: (String name, untyped value, Integer seq_id, ?String origin) -> Hash[Symbol, untyped]

def to_value: (Object value) -> Object

Expand Down

0 comments on commit a6b9175

Please sign in to comment.