Skip to content

Commit

Permalink
Ack expected non-exhaustive pattern match (#5126)
Browse files Browse the repository at this point in the history
  • Loading branch information
RustedBones authored Dec 19, 2023
1 parent 17619e9 commit 1671db7
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.google.protobuf.ByteString
import com.spotify.scio.avro.types.MacroUtil._
import org.apache.avro.{JsonProperties, Schema}
import org.apache.avro.Schema.Field
import org.typelevel.scalaccompat.annotation.nowarn

import scala.jdk.CollectionConverters._
import scala.reflect.runtime.universe
Expand Down Expand Up @@ -102,8 +103,8 @@ private[types] object SchemaProvider {
t.typeSymbol.annotations
.find(_.tree.tpe.toString == tpe)
.map { a =>
val q"new $_($v)" = a.tree
val Literal(Constant(s)) = v
val q"new $_($v)" = a.tree: @nowarn
val Literal(Constant(s)) = v: @nowarn
s.toString
}
}
Expand All @@ -114,8 +115,8 @@ private[types] object SchemaProvider {
_.annotations
.find(_.tree.tpe.toString == tpe)
.map { a =>
val q"new $_($v)" = a.tree
val Literal(Constant(s)) = v
val q"new $_($v)" = a.tree: @nowarn
val Literal(Constant(s)) = v: @nowarn
s.toString
}
}
Expand Down
3 changes: 2 additions & 1 deletion scio-core/src/main/scala/com/spotify/scio/Args.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.spotify.scio

import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Splitter
import org.typelevel.scalaccompat.annotation.nowarn

import scala.jdk.CollectionConverters._
import scala.util.control.NonFatal
Expand All @@ -42,7 +43,7 @@ object Args {

val propertyMap = properties
.map { s =>
val Array(k, v) = s.split("=", 2)
val Array(k, v) = s.split("=", 2): @nowarn
(k, Splitter.onPattern(",(?=([^\"]*\"[^\"]*\")*[^\"]*$)").split(v).asScala)
}
.groupBy(_._1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ sealed trait SCollection[T] extends PCollectionWrapper[T] {
* @group collection
*/
def partition(p: T => Boolean): (SCollection[T], SCollection[T]) = {
val Seq(left, right) = partition(2, t => if (p(t)) 0 else 1)
val Seq(left, right) = partition(2, t => if (p(t)) 0 else 1): @nowarn
(left, right)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.spotify.scio.bigquery.types

import com.spotify.scio.bigquery.BigQuerySysProps

import scala.annotation.nowarn
import scala.reflect.macros._
import scala.reflect.runtime.universe._

Expand Down Expand Up @@ -52,7 +53,7 @@ private[types] object MacroUtil {
fields
.filter { s =>
try {
val AnnotatedType(a, _) = s.asMethod.returnType
val AnnotatedType(a, _) = s.asMethod.returnType: @nowarn
a.exists(_.tree.tpe == typeOf[BigQueryTag])
} catch {
case _: MatchError => false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.joda.time.{Instant, LocalDate, LocalDateTime, LocalTime}
import scala.jdk.CollectionConverters._
import scala.reflect.runtime.universe._
import com.spotify.scio.util.Cache
import org.typelevel.scalaccompat.annotation.nowarn

private[types] object SchemaProvider {
private[this] val AvroSchemaCache = Cache.concurrentHashMap[String, Schema]
Expand Down Expand Up @@ -120,8 +121,8 @@ private[types] object SchemaProvider {
_.annotations
.find(_.tree.tpe.toString == tpe)
.map { a =>
val q"new $_($v)" = a.tree
val Literal(Constant(s)) = v
val q"new $_($v)" = a.tree: @nowarn
val Literal(Constant(s)) = v: @nowarn
s.toString
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Charsets
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.hash.Hashing
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.io.Files
import org.slf4j.LoggerFactory
import org.typelevel.scalaccompat.annotation.nowarn

import scala.annotation.nowarn
import scala.jdk.CollectionConverters._
import scala.collection.mutable.{Buffer => MBuffer, Map => MMap}
import scala.reflect.macros._
Expand All @@ -53,7 +53,7 @@ private[types] object TypeProvider {
case Nil => c.abort(c.enclosingPosition, "Missing table specification")
case l => l
}
val (table: String, _) :: _ = args
val (table: String, _) :: _ = args: @nowarn
val tableSpec =
BigQueryPartitionUtil.latestTable(bigquery, formatString(args.map(_._1)))
val schema = bigquery.tables.schema(tableSpec)
Expand All @@ -79,10 +79,11 @@ private[types] object TypeProvider {
}

def schemaImpl(c: blackbox.Context)(annottees: c.Expr[Any]*): c.Expr[Any] = {
val (schemaString: String, _) :: _ = extractArgs(c) match {
val args = extractArgs(c) match {
case Nil => c.abort(c.enclosingPosition, "Missing schema")
case l => l
}
val (schemaString: String, _) :: _ = args: @nowarn
val schema = BigQueryUtil.parseSchema(schemaString)
schemaToType(c)(schema, annottees, Nil, Nil)
}
Expand Down Expand Up @@ -124,7 +125,7 @@ private[types] object TypeProvider {
case Nil => c.abort(c.enclosingPosition, "Missing query")
case l => l
}
val (queryFormat: String, _) :: queryArgs = extractedArgs
val (queryFormat: String, _) :: queryArgs = extractedArgs: @nowarn
val query = BigQueryPartitionUtil.latestQuery(bigquery, formatString(extractedArgs.map(_._1)))
val schema = bigquery.query.schema(query)
val traits = List(tq"${p(c, SType)}.HasQuery")
Expand Down Expand Up @@ -478,7 +479,7 @@ private[types] object TypeProvider {

if (originalCompanion.isDefined) {
val q"$mods object $cName extends { ..$_ } with ..$parents { $_ => ..$body }" =
originalCompanion.get
originalCompanion.get: @nowarn
// need to filter out Object, otherwise get duplicate Object error
// also can't get a FQN of scala.AnyRef which gets erased to java.lang.Object, can't find a
// sane way to =:= scala.AnyRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package com.spotify.scio.coders

import com.spotify.scio.{FeatureFlag, MacroSettings, MagnoliaMacros}
import org.typelevel.scalaccompat.annotation.unused
import org.typelevel.scalaccompat.annotation.{nowarn, unused}

import scala.reflect.macros._

Expand Down Expand Up @@ -48,7 +48,7 @@ private[coders] object CoderMacros {
val show = MacroSettings.showCoderFallback(c) == FeatureFlag.Enable

val wtt = weakTypeOf[T]
val TypeRef(_, sym, args) = wtt
val TypeRef(_, sym, args) = wtt: @nowarn

val typeName = sym.name
val params = args.headOption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.apache.beam.sdk.extensions.smb.{SortedBucketIO, SortedBucketIOUtil, T
import org.apache.beam.sdk.transforms.join.{CoGbkResult, CoGroupByKey, KeyedPCollectionTuple}
import org.apache.beam.sdk.values.KV
import com.spotify.scio.smb.SortMergeTransform
import org.typelevel.scalaccompat.annotation.nowarn

import scala.jdk.CollectionConverters._
final class SMBMultiJoin(private val self: ScioContext) {
Expand Down Expand Up @@ -2070,7 +2071,7 @@ final class SMBMultiJoin(private val self: ScioContext) {
reads: SortedBucketIO.Read[_]*
): SCollection[KV[K, CoGbkResult]] = {
val testInput = TestDataManager.getInput(self.testId.get)
val read :: rs = reads.asInstanceOf[Seq[SortedBucketIO.Read[Any]]].toList
val read :: rs = reads.asInstanceOf[Seq[SortedBucketIO.Read[Any]]].toList: @nowarn
val test = testInput[(K, Any)](SortedBucketIOUtil.testId(read)).toSCollection(self)
val keyed = rs
.foldLeft(KeyedPCollectionTuple.of(read.getTupleTag, test.toKV.internal)) { (kpt, r) =>
Expand Down
3 changes: 2 additions & 1 deletion scripts/smb_multijoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def testCoGroup(out):
\t\treads: SortedBucketIO.Read[_]*
\t): SCollection[KV[K, CoGbkResult]] = {
\t\tval testInput = TestDataManager.getInput(self.testId.get)
\t\tval read :: rs = reads.asInstanceOf[Seq[SortedBucketIO.Read[Any]]].toList
\t\tval read :: rs = reads.asInstanceOf[Seq[SortedBucketIO.Read[Any]]].toList: @nowarn
\t\tval test = testInput[(K, Any)](SortedBucketIOUtil.testId(read)).toSCollection(self)
\t\tval keyed = rs
\t\t\t.foldLeft(KeyedPCollectionTuple.of(read.getTupleTag, test.toKV.internal)) { (kpt, r) =>
Expand Down Expand Up @@ -196,6 +196,7 @@ def main(out):
import org.apache.beam.sdk.transforms.join.{CoGbkResult, CoGroupByKey, KeyedPCollectionTuple}
import org.apache.beam.sdk.values.KV
import com.spotify.scio.smb.SortMergeTransform
import org.typelevel.scalaccompat.annotation.nowarn
import scala.jdk.CollectionConverters._
final class SMBMultiJoin(private val self: ScioContext) {'''.lstrip('\n'), file=out)
Expand Down

0 comments on commit 1671db7

Please sign in to comment.