Coder Social home page Coder Social logo

Comments (6)

laike9m avatar laike9m commented on June 18, 2024

Yes, this is a known issue. I haven't thought of good ways to solve it

from python-type-challenges.

laike9m avatar laike9m commented on June 18, 2024

Took another look. "advanced-forward" should be easy to fix, but never2 is hard, as I haven't found a way to force pyright to fail..

from python-type-challenges.

F-park avatar F-park commented on June 18, 2024

If we can insert some imports before user_code and add "reportUnusedImport": true to pyrightconfig.json, it is easy to solve.


advanced-forward need to force user to annotate return_type for function

# advanced-forward-fix
## End of your code ##
+# pyright: analyzeUnannotatedFunctions=false
from typing import assert_type

inst = MyClass(x=1)
assert_type(inst.copy(), MyClass)

from python-type-challenges.

laike9m avatar laike9m commented on June 18, 2024

Actually, I find that pyright will ignore whatever code following raise, since it thinks that those code is unreachable.

Example

So it really seems to have no solution..

from python-type-challenges.

F-park avatar F-park commented on June 18, 2024

So it really seems to have no solution..

image

mypy can detect the name-defined error although code is unreachable, I think we can mix mypy with pyright.


If we add the below to pyproject.toml, mypy will show test.py:4: error: Statement is unreachable [unreachable]

[tool.mypy]
warn_unreachable = true

from python-type-challenges.

laike9m avatar laike9m commented on June 18, 2024

Using sourcery is a no-go, using mypy maybe could be an option but certainly would complicate things. Another option is to create a special rule just for raise and warn users about it. I'll leave this one open and think about it.

from python-type-challenges.

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.