我正在使用替罪羊进行静态代码分析,但收到警告消息
from PIL import Image, ImageDraw
im = Image.open('test.png')
# I'm creating a random shape here
mask = Image.new('RGBA', im.size)
d = ImageDraw.Draw(mask)
d.polygon(((20, 20), (20, 50), (100, 100), (100, 20)), fill='#000')
out = Image.new('RGBA', im.size)
out.paste(im, (0, 0), mask)
out.show()
这是我的代码
fruitless type test: a value of type Option[akka.actor.ActorSystem] cannot also be a akka.actor.ActorSystem
在本节中,我收到警告消息
object ActorSystemSetting extends ActorSystemSettingTrait{
val config = ConfigFactory.load()
val log = LoggerFactory.getLogger(this.getClass)
var actorSystem : Option[ActorSystem] = None
def createActorSystem: Option[ActorSystem] = {
actorSystem = Option(ActorSystem("ArteciateActorSystem", config))
actorSystem
}
def getActorSystem : Option[ActorSystem] ={
if (actorSystem == None){
createActorSystem
}
else{
log.debug("ActorSystem is not null")
}
actorSystem
}
}
答案 0 :(得分:4)
您需要更改此
Option(ActorSystemSetting.getActorSystem) match {
仅此:
ActorSystemSetting.getActorSystem match {
ActorSystemSetting.getActorSystem
已经返回Option(ActorSystem)
,因此您无需将其包装在另一个Option
中。
它不起作用,因为您尝试将Option[Option[ActorSystem]]
类型的值与Some(system: ActorSystem)
类型的Option[ActorSystem]
匹配,因此它永远无法匹配。