草庐IT

Deprecated

全部标签

python - 如何修复 : W602 deprecated form of raising exception

如果我使用pylint(通过sublimerlinter),我会收到以下警告消息:W602已弃用的引发异常的形式这是我在代码中使用异常的方式:ifCONDITION==True:raiseValueError,HELPING_EXPLANATION 最佳答案 像这样提出你的异常:ifCONDITION==True:raiseValueError(HELPING_EXPLANATION)来自PEP8--StyleGuideforPythonCode-ProgrammingRecommendations:Whenraisinganexc

python - python标准库中的装饰器(特别是@deprecated)

我需要将例程标记为已弃用,但显然没有可弃用的标准库装饰器。我知道它的配方和警告模块,但我的问题是:为什么这个(常见)任务没有标准库装饰器?附加问题:标准库中是否有标准装饰器? 最佳答案 以下是一些片段,根据Leandro引用的片段进行了修改:importwarningsimportfunctoolsdefdeprecated(func):"""Thisisadecoratorwhichcanbeusedtomarkfunctionsasdeprecated.Itwillresultinawarningbeingemittedwhen

java - 标记为 "deprecated"的 API 方法何时真正消失?

我正在审查我的一位同事刚刚所做的更改,他添加了一堆对Date.toMonth()、Date.toYear()的调用code>和其他已弃用的Date方法。所有这些方法在JDK1.1中都已弃用,但他坚持认为可以使用它们,因为它们还没有消失(我们正在使用JDK1.5),我说它们现在可能会消失,他应该使用日历方法。Sun/Oracle是否真的说过这些东西会消失,还是@deprecated只是意味着你失去了风格点? 最佳答案 关于API,...没有指定它们将很快被删除。IncompatibilitiesinJ2SE5.0(since1.4.2

java - @deprecated 与 @Deprecated

这个问题在这里已经有了答案:HowtodeclareormarkaJavamethodasdeprecated?(6个回答)关闭8年前。我可以使用@Deprecated注释来弃用函数或类。但是在javadoc注释本身中有一个@deprecatedjavadoc标记,将类/函数标记为已弃用。@deprecatedjavadoc标签是否真的使类/函数被弃用了? 最佳答案 @Deprecated是编译器读取的注解,用于将方法标记为编译器已弃用,如果使用该方法,将生成弃用编译时警告。@deprecated是一个javadoc标记,用于提供有

java - Spring 启动 : SpringBootServletInitializer is deprecated

我正在尝试按照this将SpringBoot应用程序部署到JBoss.它运行良好,但SpringBootServletInitializer在1.4.0.RELEASE中已弃用。我应该使用哪一个?Maven依赖org.springframework.bootspring-boot-starter-parent1.4.0.RELEASEJava代码importorg.springframework.boot.SpringApplication;importorg.springframework.boot.autoconfigure.EnableAutoConfiguration;impo

php - 使用 PHP zip 扩展构建的 Docker 镜像显示 "bundled libzip is deprecated"警告

我有一个Dockerfile带有这样的构建命令:#installsomebaseextensionsRUNapt-getinstall-y\zlib1g-dev\zip\&&docker-php-ext-installzip我从构建输出中收到此警告:WARNING:Useofbundledlibzipisdeprecatedandwillberemoved.configure:WARNING:Somefeaturessuchasencryptionandbzip2arenotavailable.configure:WARNING:Usesystemlibraryand--with-li

node.js - express js错误: "express deprecated res.sendfile: Use res.sendFile instead"

设置路径的正确方法是什么?在我的应用程序中,我使用此代码设置发送文件的路径。app.get('/',function(req,res){//get,put,post,deleteres.sendfile(__dirname+'/client/views/index.html');});但它给出了这个错误:expressdeprecatedres.sendfile:Useres.sendFileinsteadserver.js:22:6可以指出这里的错误是什么。请 最佳答案 改变这个app.get('/',function(req,r

node.js - express js错误: "express deprecated res.sendfile: Use res.sendFile instead"

设置路径的正确方法是什么?在我的应用程序中,我使用此代码设置发送文件的路径。app.get('/',function(req,res){//get,put,post,deleteres.sendfile(__dirname+'/client/views/index.html');});但它给出了这个错误:expressdeprecatedres.sendfile:Useres.sendFileinsteadserver.js:22:6可以指出这里的错误是什么。请 最佳答案 改变这个app.get('/',function(req,r

java - 警告 : The method assertEquals from the type Assert is deprecated

由于方法Assert.assertEquals已被弃用,我们现在应该使用哪种方法?以下代码:Stringarg1="test";Stringarg2="me";Assert.assertEquals(arg1,arg2);给出以下警告:MultiplemarkersatthislineThemethodassertEquals(String,String)fromthetypeAssertisdeprecatedThetypeAssertisdeprecated 最佳答案 您正在使用junit.framework.Assert而不是

objective-c - 使用 respondsToSelector 时抑制 "' …' is deprecated"

我通过在运行时选择最新的API来支持10.4+:if([fileManagerrespondsToSelector:@selector(removeItemAtPath:error:)])[fileManagerremoveItemAtPath:downloadDirerror:NULL];else[fileManagerremoveFileAtPath:downloadDirhandler:nil];在这种情况下,10.5及更高版本将使用removeItemAtPath:error:,而10.4将使用removeFileAtPath:handler:。很好,但我仍然收到旧方法的编译器