GithubHelp home page GithubHelp logo

Warn about string exceptions about pyflakes HOT 6 CLOSED

pycqa avatar pycqa commented on August 28, 2024
Warn about string exceptions

from pyflakes.

Comments (6)

pyflakes-bot avatar pyflakes-bot commented on August 28, 2024

Original comment by bitglue (@bitglue?) on Launchpad:


Pyflakes still supports python 2.5, where string exceptions are still allowed. Pyflakes has no way to know what the target python version is, so must take the conservative approach and assume the code might be targeted at python 2.5 and string exceptions are valid.

For code targeted at later versions, I suggest catching these errors in unit tests.

from pyflakes.

pyflakes-bot avatar pyflakes-bot commented on August 28, 2024

Original comment by mithrandi (@mithrandi?) on Launchpad:


Unfortunately the most common occurrences of string exceptions are in exceptional code paths that are never (and perhaps have never) been tested; but perhaps pyflakes is not the right tool for dealing with this problem (although, since pyflakes already has to deal with Python 2 vs Python 3, I could imagine support being added for more precise version targets).

from pyflakes.

pyflakes-bot avatar pyflakes-bot commented on August 28, 2024

Original comment by florent.x (@florentx?) on Launchpad:


According to the Python documentation:

« Raising of strings as exceptions, as in the statement raise "Error occurred", is deprecated in Python 2.5 and will trigger a warning. The aim is to be able to remove the string-exception feature in a few releases. »
https://docs.python.org/2.7/whatsnew/2.5.html#pep-352-exceptions-as-new-style-classes

So we could probably enforce this deprecation in a linter tool which supports Python 2.5.

With the examples posted in the initial requests, I think that this checker will be easy to implement for "simple cases" as a warning in the "pep8.py" tool, which does non-AST analysis of the code.

from pyflakes.

pyflakes-bot avatar pyflakes-bot commented on August 28, 2024

Original comment by adiroiban (@adiroiban?) on Launchpad:


+1 for fixing this in pep8.py

from pyflakes.

asottile avatar asottile commented on August 28, 2024

Should we close this as pyflakes no longer supports python2.5?

from pyflakes.

bitglue avatar bitglue commented on August 28, 2024

yep.

from pyflakes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.