Code Monkey home page Code Monkey logo

Comments (9)

gvanrossum avatar gvanrossum commented on June 27, 2024 1

Whatever solution we pick should also be applied to decorated classes.

from typed_ast.

ethanhs avatar ethanhs commented on June 27, 2024

In python/mypy#3871 we seem to be of the opinion that adding class_lineno and def_lineno attributes are the best solution.

from typed_ast.

ethanhs avatar ethanhs commented on June 27, 2024

To be clear, I am adding this to ClassDef, FunctionDef, and AsyncFunctionDef.

from typed_ast.

ethanhs avatar ethanhs commented on June 27, 2024

It appears this was fixed in python/cpython#9731. Perhaps we could backport that change after the update to being based on the 3.7 ast?

from typed_ast.

ilevkivskyi avatar ilevkivskyi commented on June 27, 2024

Taking into account size of the fix, can we backport just the fix now? Supporting 3.7 in typed_ast may take time because of the ASYNC problems, while this fix looks small and well localized.

from typed_ast.

ethanhs avatar ethanhs commented on June 27, 2024

Sure, I'd be happy to make a PR.

from typed_ast.

ilevkivskyi avatar ilevkivskyi commented on June 27, 2024

OK, let's do this then.

from typed_ast.

gvanrossum avatar gvanrossum commented on June 27, 2024

So... It looks like we took a different path. In Python 3.8's ast this is fixed, but it was not fixed in Python 3.7's ast. Typed_ast is now based on Python 3.7's ast.

Should we do it or not? I worry that just changing the lineno attribute of FunctionDef and ClassDef nodes will break tons of users' code since it changes where # type: ignore comments would have to go. So maybe let sleeping dogs lie?

from typed_ast.

gvanrossum avatar gvanrossum commented on June 27, 2024

Let's leave typed_ast alone. With Python 3.8 we can support # type: ignore backward compatibility, see python/mypy#3871 (comment) and further comments. For 3.7 and before we'll stick with the status quo.

from typed_ast.

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.