Skip to content

Commit

Permalink
Update scalafmt-core to 3.8.3 (#3956)
Browse files Browse the repository at this point in the history
Co-authored-by: scala-steward <scala-steward>
  • Loading branch information
softwaremill-ci authored Jul 27, 2024
1 parent 1a8d332 commit 6708163
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ e003ec3b61e3bd582ae6a5200177fa6433099c09

# Scala Steward: Reformat with scalafmt 3.8.2
9b44bd1451b796259b0592afe54bb5891f63f48e

# Scala Steward: Reformat with scalafmt 3.8.3
d743a8c6f793a5b30c8f14cfd57a367a4ffee4cd
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.8.2
version = 3.8.3
maxColumn = 140
runner.dialect = scala3
fileOverride {
Expand Down
4 changes: 2 additions & 2 deletions core/src/test/scala-3/sttp/tapir/EndpointScala3Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class EndpointScala3Test extends AnyFlatSpec with Matchers:
)
)
}

it should "compile when using parameterless sealed traits" in {
endpoint.get
.out(
Expand Down Expand Up @@ -52,4 +52,4 @@ object EndpointScala3Test:
sealed trait ParameterlessSealed
object ParameterlessSealed:
case object Case1 extends ParameterlessSealed
case object Case2 extends ParameterlessSealed
case object Case2 extends ParameterlessSealed
18 changes: 12 additions & 6 deletions core/src/test/scala/sttp/tapir/SchemaTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,16 @@ class SchemaTest extends AnyFlatSpec with Matchers {

it should "generate correct names for Eithers with parameterized types" in {
import sttp.tapir.generic.auto._
implicitly[Schema[Either[Int, Int]]].name shouldBe None
implicitly[Schema[Either[Int, Int]]].name shouldBe None
implicitly[Schema[Either[SomeValueInt, Int]]].name shouldBe None
implicitly[Schema[Either[SomeValueInt, SomeValueInt]]].name shouldBe Some(
SName("Either", List("sttp.tapir.SchemaTest.SomeValueInt", "sttp.tapir.SchemaTest.SomeValueInt"))
)
implicitly[Schema[Either[SomeValueInt, Node[SomeValueString[Boolean]]]]].name shouldBe Some(
SName("Either", List("sttp.tapir.SchemaTest.SomeValueInt", "sttp.tapir.SchemaTest.Node", "sttp.tapir.SchemaTest.SomeValueString", "scala.Boolean"))
SName(
"Either",
List("sttp.tapir.SchemaTest.SomeValueInt", "sttp.tapir.SchemaTest.Node", "sttp.tapir.SchemaTest.SomeValueString", "scala.Boolean")
)
)
implicitly[Schema[Either[SomeValueInt, Node[String]]]].name shouldBe Some(
SName("Either", List("sttp.tapir.SchemaTest.SomeValueInt", "sttp.tapir.SchemaTest.Node", "java.lang.String"))
Expand All @@ -224,15 +227,18 @@ class SchemaTest extends AnyFlatSpec with Matchers {
SName("Either", List("sttp.tapir.SchemaTest.Node", "scala.Boolean", "sttp.tapir.SchemaTest.SomeValueInt"))
)
}

it should "generate correct names for Maps with parameterized types" in {
import sttp.tapir.generic.auto._
type Tree[A] = Either[A, Node[A]]
val schema1: Schema[Map[SomeValueInt, Node[SomeValueString[Boolean]]]] = Schema.schemaForMap(_.toString)
val schema1: Schema[Map[SomeValueInt, Node[SomeValueString[Boolean]]]] = Schema.schemaForMap(_.toString)
schema1.name shouldBe Some(
SName("Map", List("sttp.tapir.SchemaTest.SomeValueInt", "sttp.tapir.SchemaTest.Node", "sttp.tapir.SchemaTest.SomeValueString", "scala.Boolean"))
SName(
"Map",
List("sttp.tapir.SchemaTest.SomeValueInt", "sttp.tapir.SchemaTest.Node", "sttp.tapir.SchemaTest.SomeValueString", "scala.Boolean")
)
)
val schema2: Schema[Map[Node[Boolean], Node[String]]] = Schema.schemaForMap(_.toString)
val schema2: Schema[Map[Node[Boolean], Node[String]]] = Schema.schemaForMap(_.toString)
schema2.name shouldBe Some(
SName("Map", List("sttp.tapir.SchemaTest.Node", "scala.Boolean", "sttp.tapir.SchemaTest.Node", "java.lang.String"))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private[asyncapi] object ExampleConverter {
case WebSocketFrame.Text(payload, _, _) =>
Some(MessageExample(headers = None, Some(ExampleSingleValue(payload)), example.name, example.summary))
case WebSocketFrame.Binary(_, _, _) => None
case _: WebSocketFrame.Control => None
case _: WebSocketFrame.Control => None
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ object IntersectionTypeMirror {
tpe.dealias match
case AndType(left, right) => concatTypes(rec(left), rec(right))
case t =>
// Intentionally using `tpe` instead of `t`. Dealiased representation `t` "loses" information
// about the original type from the intersection. For example, an Iron predicate `MinLength[N]`
// would be dealiased to `DescribedAs[Length[GreaterEqual[N]], _]`.
// Intentionally using `tpe` instead of `t`. Dealiased representation `t` "loses" information
// about the original type from the intersection. For example, an Iron predicate `MinLength[N]`
// would be dealiased to `DescribedAs[Length[GreaterEqual[N]], _]`.
// Then, a given `ValidatorForPredicate[T, MinLength[N]]` would not be used in implicit resolution.
prependTypes(tpe, TypeRepr.of[EmptyTuple])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ object UnionTypeMirror {
val (c1, rec1) = rec(left)
val (c2, rec2) = rec(right)
(c1 + c2, concatTypes(rec1, rec2))
case t =>
// Intentionally using `tpe` instead of `t`. Dealiased representation `t` "loses" information
// about the original type from the union. For example, an Iron predicate `MinLength[N]`
// would be dealiased to `DescribedAs[Length[GreaterEqual[N]], _]`.
case t =>
// Intentionally using `tpe` instead of `t`. Dealiased representation `t` "loses" information
// about the original type from the union. For example, an Iron predicate `MinLength[N]`
// would be dealiased to `DescribedAs[Length[GreaterEqual[N]], _]`.
// Then, a given `ValidatorForPredicate[T, MinLength[N]]` would not be used in implicit resolution.
(1, prependTypes(tpe, TypeRepr.of[EmptyTuple]))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TapirJsonJsoniterTests extends AnyFlatSpecLike with Matchers {
val error = failure.error.asInstanceOf[JsonDecodeException]
error.errors shouldEqual List(JsonError("missing required field \"name\", offset: 0x00000001", Nil))
tapirCodecWithHexDump.decode("{}") should matchPattern {
case DecodeResult.Error(_, JsonDecodeException(errs, _: JsonReaderException)) if errs.head.msg.contains("buf:") =>
case DecodeResult.Error(_, JsonDecodeException(errs, _: JsonReaderException)) if errs.head.msg.contains("buf:") =>
}
error.underlying shouldBe a[JsonReaderException]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ trait FinatraServerInterpreter extends Logging {

private[finatra] def path(input: EndpointInput[_]): String = {
val basicInputs = input.asVectorOfBasicInputs()
val p = basicInputs
.collect {
case segment: EndpointInput.FixedPath[_] => segment.show
case PathCapture(Some(name), _, _) => s"/:$name"
case PathCapture(_, _, _) => "/:param"
case EndpointInput.PathsCapture(_, _) => "/:*"
}
.mkString
val p = basicInputs.collect {
case segment: EndpointInput.FixedPath[_] => segment.show
case PathCapture(Some(name), _, _) => s"/:$name"
case PathCapture(_, _, _) => "/:param"
case EndpointInput.PathsCapture(_, _) => "/:*"
}.mkString
if (p.isEmpty) "/:*"
// checking if there's an input which rejects trailing slashes; otherwise the default behavior is to accept them
else if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ZHttp4sTestServerInterpreter extends TestServerInterpreter[Task, ZioStream
.withHttpWebSocketApp(service)
.resource
.map(_.address.getPort)
.mapK(new ~>[Task, IO] {
.mapK(new ~>[Task, IO] {
// Converting a ZIO effect to an Cats Effect IO effect
def apply[B](fa: Task[B]): IO[B] = IO.fromFuture(Unsafe.unsafe(implicit u => IO(Runtime.default.unsafe.runToFuture(fa))))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,6 @@ class ServerOneOfTests[F[_], OPTIONS, ROUTE](
(backend, baseUri) =>
basicRequest.get(uri"$baseUri/mapping?num=1").send(backend).map(_.code shouldBe StatusCode.Ok) >>
basicRequest.get(uri"$baseUri/mapping?num=2").send(backend).map(_.code shouldBe StatusCode.Accepted)
},
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ trait ZioHttpInterpreter[R] {
val e = se.endpoint
val inputs = e.securityInput.and(e.input).asVectorOfBasicInputs()

// Creating the path template - no-trailing-slash inputs are treated as wildcard inputs, as they are usually
// accompanied by endpoints which handle wildcard path inputs, when the `/` is present (to serve files). They
// Creating the path template - no-trailing-slash inputs are treated as wildcard inputs, as they are usually
// accompanied by endpoints which handle wildcard path inputs, when the `/` is present (to serve files). They
// need to end up in the same group (see below), so that they are disambiguated by tapir's logic.
val pathTemplate = inputs.foldLeft("") { case (p, component) =>
component match {
Expand Down Expand Up @@ -120,7 +120,7 @@ trait ZioHttpInterpreter[R] {

// Grouping the endpoints by path template. This way, if there are multiple endpoints with/without trailing slash or
// with path wildcards, they will end up in the same group, and they will be disambiguated by the tapir logic.
// That's because there's not way currently to create a zio-http route pattern which would match on
// That's because there's not way currently to create a zio-http route pattern which would match on
// no-trailing-slashes. A group also includes multiple endpoints with different methods, but same path.
val widenedSesGroupedByPathPrefixTemplate = widenedSes.zipWithIndex
.map { case (se, index) => toPattern(se, index) }
Expand Down

0 comments on commit 6708163

Please sign in to comment.