-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: interpreted classes cannot inherit from compiled traits #305
Comments
We have the same problem. Interestingly, I cannot reproduce it on my local machine, it happens only in the CI. So there must be some environment-specific cause. |
@anpr originally that was the case for me (CI is GitHub Action's Yeah the error is interesting, I think it is emitted to refurb dir1 file.py -- --verbose --verbose >> logs 2>&1 Will output a ton of build logs to a
So it's some error at runtime after |
Thank you for reporting this, this seems to be an issue with the latest 1.7.0 release of Mypy. I'm currently investigating, but downgrading/pinning Mypy to version 1.6.1 should fix it for the time being. |
I just confirmed downgrading |
I was able to reproduce the following error: from native import Trait, create
from testutil import assertRaises
with assertRaises(TypeError, "traits may not be directly created"):
Trait()
with assertRaises(TypeError, "traits may not be directly created"):
create()
class Sub(Trait):
pass
with assertRaises(TypeError, "interpreted classes cannot inherit from compiled traits"):
Sub() similiar to: |
I am also encountering this problem. But for me it's very weird. On my local, where it was also successful, today I got the same error after running
Some more details.pre-commit-config.yaml: default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-json
- id: check-toml
- id: check-yaml
- repo: https://github.com/psf/black
rev: 23.10.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1
hooks:
- id: mypy
additional_dependencies: [types-requests]
- repo: https://github.com/dosisod/refurb
rev: v1.22.1
hooks:
- id: refurb
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.1.0"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix] .gitlab-ci.yml style:
stage: test
image: python:3.12
before_script:
- pip install -U pip wheel setuptools pre-commit
- pre-commit install
script:
- pre-commit run --all-files Failing log (today):
Successful log (4 days ago)
Hope this can help... I have no clue what it could be. |
@francesco086 for now, we need to add an - repo: https://github.com/dosisod/refurb
rev: v1.22.2
hooks:
- id: refurb
additional_dependencies:
- mypy<1.7 # SEE: https://github.com/dosisod/refurb/issues/305 Or alternately, the |
Oh, got it! Many thanks! It works now :) |
@jamesbraza I'm considering capping Mypy to <1.7.0 since I can't seem to find any viable work-arounds. If I can't find a solution in the next few hours I'll cap it until I can find a better solution (or it gets fixed upstream). |
Okay sounds good 👍. In general, I am wondering if |
Temporarily fixes #305. Specifically, this error is being caused by this line: https://github.com/python/mypy/blob/e4355948d797600c7b76da0a916fc5f29d10448e/mypy/traverser.py#L97 Because `TraverserVisitor` now is a `trait` you cannot extend from it. There doesn't seem to be a way to get around this on my end, so I'm pinning Mypy as a workaround until I find a solution or something changes upstream with Mypy.
Temporarily fixes #305. Specifically, this error is being caused by this line: https://github.com/python/mypy/blob/e4355948d797600c7b76da0a916fc5f29d10448e/mypy/traverser.py#L97 Because `TraverserVisitor` now is a `trait` you cannot extend from it. There doesn't seem to be a way to get around this on my end, so I'm pinning Mypy as a workaround until I find a solution or something changes upstream with Mypy.
Didn't mean to close this. I still consider this an issue, #306 is a bandaid fix until I find a better workaround. |
Closed by #309 |
Has your issue already been fixed?
master
branch? See the docs for instructions on how to setup a local build of Refurb.The Bug
Running
refurb
like so emits a strange error:I tried running
refurb --verbose --verbose --verbose dir1 file.py
, and it doesn't add anything meaningful to the output. I am at the root causing level of this issue, I am not even sure why this message is being emitted.My package is internal, so I can't share the source code. Can you help me figure out how to add verbosity to
refurb
so I can properly root cause this issue?Version Info
Python Version
Python 3.11.5
Config File
Extra Info
This issue is a continuation of the saga after #302
I found python/mypy#6706 with a related message, but it was fixed a long time ago so I am not sure what the issue is here.
The text was updated successfully, but these errors were encountered: