Skip to content
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

Closed
2 tasks done
jamesbraza opened this issue Nov 11, 2023 · 12 comments · Fixed by #306
Closed
2 tasks done

[Bug]: interpreted classes cannot inherit from compiled traits #305

jamesbraza opened this issue Nov 11, 2023 · 12 comments · Fixed by #306
Assignees
Labels
bug Something isn't working mypy An upstream issue with Mypy

Comments

@jamesbraza
Copy link

Has your issue already been fixed?

  • Have you checked to see if your issue still exists on the master branch? See the docs for instructions on how to setup a local build of Refurb.
  • Have you looked at the open/closed issues to see if anyone has already reported your issue?

The Bug

Running refurb like so emits a strange error:

> mypy dir1 file.py
# nothing
> refurb dir1 file.py
interpreted classes cannot inherit from compiled traits

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

Refurb: v1.22.2
Mypy: v1.7.0

Python Version

Python 3.11.5

Config File

[tool.mypy]
check_untyped_defs = true
error_summary = false
platform = "linux"
pretty = true
show_column_numbers = true
show_error_codes = true
show_error_context = true
warn_redundant_casts = true
warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true

[[tool.mypy.overrides]]
ignore_missing_imports = true
module = [
    "fastapi_socketio",  # SEE: https://github.com/pyropy/fastapi-socketio/issues/27
    "fsspec",  # SEE: https://github.com/fsspec/filesystem_spec/issues/625
    "huggingface_hub",  # SEE: https://github.com/huggingface/huggingface_hub/issues/1662
    "rapidjson",  # SEE: https://github.com/python-rapidjson/python-rapidjson/issues/190
    "s3fs",  # SEE: https://github.com/fsspec/s3fs/issues/383
    "setuptools_scm",  # SEE: https://github.com/pypa/setuptools_scm/issues/501
    "socketio.*",  # SEE: https://github.com/miguelgrinberg/python-socketio/issues/1276
    "streamlit_pydantic",
    "transformers",
]

[tool.refurb]
enable_all = true
ignore = [
    "FURB103",
    "FURB141",
    "FURB144",
    "FURB147",
    "FURB150",
    "FURB155",
]

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.

@anpr
Copy link

anpr commented Nov 11, 2023

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.

@jamesbraza
Copy link
Author

@anpr originally that was the case for me (CI is GitHub Action's ubuntu-latest runner) too. However, when I updated to yesterday's refurb release of 1.22.2, the error started showing up on my macOS. Possibly related is, in my mypy config, I also specify platform = "linux".

Yeah the error is interesting, I think it is emitted to stderr by mypy's internals, not by refurb. However, it doesn't show up when invoking mypy directly.

refurb dir1 file.py -- --verbose --verbose >> logs 2>&1

Will output a ton of build logs to a logs file, which ends with:

LOG:  No fresh SCCs left in queue
LOG:  Build finished in 16.285 seconds with 2138 modules, and 0 errors
interpreted classes cannot inherit from compiled traits

So it's some error at runtime after mypy internal's build step

@dosisod
Copy link
Owner

dosisod commented Nov 12, 2023

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.

@jamesbraza
Copy link
Author

I just confirmed downgrading mypy<1.7 resolves this issue, thanks for sharing that. Also, python/mypy#14736 is possibly related

@dosisod dosisod pinned this issue Nov 12, 2023
@dosisod dosisod added the mypy An upstream issue with Mypy label Nov 12, 2023
@apoclyps
Copy link

I was able to reproduce the following error: interpreted classes cannot inherit from compiled traits using the example provided within by mypy:

https://github.com/python/mypy/blob/023eb4101347dd151a2ce5bf7baf5a60d2de4145/mypyc/test-data/run-traits.test#L401

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:

@francesco086
Copy link

I am also encountering this problem. But for me it's very weird.
On my master the CI pipeline was successful few days ago. Today, without any change, it fails.
What is strange, is that I have mypy pinned to 1.6.1.

On my local, where it was also successful, today I got the same error after running

pre-commit run --all-files

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):

$ pip install -U pip wheel setuptools pre-commit
Requirement already satisfied: pip in /usr/local/lib/python3.12/site-packages (23.2.1)
Collecting pip
  Obtaining dependency information for pip from https://files.pythonhosted.org/packages/47/6a/453160888fab7c6a432a6e25f8afe6256d0d9f2cbd25971021da6491d899/pip-23.3.1-py3-none-any.whl.metadata
  Downloading pip-23.3.1-py3-none-any.whl.metadata (3.5 kB)
Requirement already satisfied: wheel in /usr/local/lib/python3.12/site-packages (0.41.3)
Requirement already satisfied: setuptools in /usr/local/lib/python3.12/site-packages (68.2.2)
Collecting pre-commit
  Obtaining dependency information for pre-commit from https://files.pythonhosted.org/packages/6c/75/526915fedf462e05eeb1c75ceaf7e3f9cde7b5ce6f62740fe5f7f19a0050/pre_commit-3.5.0-py2.py3-none-any.whl.metadata
  Downloading pre_commit-3.5.0-py2.py3-none-any.whl.metadata (1.3 kB)
Collecting cfgv>=2.0.0 (from pre-commit)
  Obtaining dependency information for cfgv>=2.0.0 from https://files.pythonhosted.org/packages/c5/55/51844dd50c4fc7a33b653bfaba4c2456f06955289ca770a5dbd5fd267374/cfgv-3.4.0-py2.py3-none-any.whl.metadata
  Downloading cfgv-3.4.0-py2.py3-none-any.whl.metadata (8.5 kB)
Collecting identify>=1.0.0 (from pre-commit)
  Obtaining dependency information for identify>=1.0.0 from https://files.pythonhosted.org/packages/46/02/2581c37256119d65e6f1f47b62dd51dd3136d6b[20](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5523912904#L20)7bb49a8885a0d45c41a/identify-2.5.31-py2.py3-none-any.whl.metadata
  Downloading identify-2.5.31-py2.py3-none-any.whl.metadata (4.4 kB)
Collecting nodeenv>=0.11.1 (from pre-commit)
  Obtaining dependency information for nodeenv>=0.11.1 from https://files.pythonhosted.org/packages/1a/e6/6d2ead760a9ddb35e65740fd5a57e46aadd7b0c49861ab24f94812797a1c/nodeenv-1.8.0-py2.py3-none-any.whl.metadata
  Downloading nodeenv-1.8.0-py2.py3-none-any.whl.metadata ([21](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5523912904#L21) kB)
Collecting pyyaml>=5.1 (from pre-commit)
  Obtaining dependency information for pyyaml>=5.1 from https://files.pythonhosted.org/packages/b4/33/720548182ffa8344418126017aa1d4ab4aeec9a[22](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5523912904#L22)75f04ce3f3573d8ace8/PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Downloading PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
Collecting virtualenv>=20.10.0 (from pre-commit)
  Obtaining dependency information for virtualenv>=20.10.0 from https://files.pythonhosted.org/packages/7f/19/1f0eddcb9acf00a95793ce83417f69e0fd106c192121360af499cd6fde39/virtualenv-20.24.6-py3-none-any.whl.metadata
  Downloading virtualenv-20.24.6-py3-none-any.whl.metadata (4.5 kB)
Collecting distlib<1,>=0.3.7 (from virtualenv>=20.10.0->pre-commit)
  Obtaining dependency information for distlib<1,>=0.3.7 from https://files.pythonhosted.org/packages/43/a0/9ba967fdbd55293bacfc1507f58e316f740a3b[23](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5523912904#L23)1fc00e3d86dc39bc185a/distlib-0.3.7-py2.py3-none-any.whl.metadata
  Downloading distlib-0.3.7-py2.py3-none-any.whl.metadata (5.1 kB)
Collecting filelock<4,>=3.12.2 (from virtualenv>=20.10.0->pre-commit)
  Obtaining dependency information for filelock<4,>=3.12.2 from https://files.pythonhosted.org/packages/81/54/84d42a0bee35edba99dee7b59a8d4970eccdd44b99fe728ed912106fc781/filelock-3.13.1-py3-none-any.whl.metadata
  Downloading filelock-3.13.1-py3-none-any.whl.metadata (2.8 kB)
Collecting platformdirs<4,>=3.9.1 (from virtualenv>=20.10.0->pre-commit)
  Obtaining dependency information for platformdirs<4,>=3.9.1 from https://files.pythonhosted.org/packages/56/29/3ec311dc18804409ecf0d2b09caa976f3ae6215559306b5b530004e11156/platformdirs-3.11.0-py3-none-any.whl.metadata
  Downloading platformdirs-3.11.0-py3-none-any.whl.metadata (11 kB)
Downloading pip-23.3.1-py3-none-any.whl (2.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 26.8 MB/s eta 0:00:00
Downloading pre_commit-3.5.0-py2.py3-none-any.whl (203 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 203.7/203.7 kB 28.6 MB/s eta 0:00:00
Downloading cfgv-3.4.0-py2.py3-none-any.whl (7.2 kB)
Downloading identify-2.5.31-py2.py3-none-any.whl (98 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.9/98.9 kB 18.6 MB/s eta 0:00:00
Downloading nodeenv-1.8.0-py2.py3-none-any.whl (22 kB)
Downloading PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7[24](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5523912904#L24) kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7[25](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5523912904#L25).0/725.0 kB 60.6 MB/s eta 0:00:00
Downloading virtualenv-20.24.6-py3-none-any.whl (3.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.8/3.8 MB 100.1 MB/s eta 0:00:00
Downloading distlib-0.3.7-py2.py3-none-any.whl (468 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 kB 45.7 MB/s eta 0:00:00
Downloading filelock-3.13.1-py3-none-any.whl (11 kB)
Downloading platformdirs-3.11.0-py3-none-any.whl (17 kB)
Installing collected packages: distlib, pyyaml, platformdirs, pip, nodeenv, identify, filelock, cfgv, virtualenv, pre-commit
  Attempting uninstall: pip
    Found existing installation: pip 23.2.1
    Uninstalling pip-23.2.1:
      Successfully uninstalled pip-23.2.1
Successfully installed cfgv-3.4.0 distlib-0.3.7 filelock-3.13.1 identify-2.5.[31](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5523912904#L31) nodeenv-1.8.0 pip-23.3.1 platformdirs-3.11.0 pre-commit-3.5.0 pyyaml-6.0.1 virtualenv-20.24.6
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
$ pre-commit run --all-files
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-mypy.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-mypy:types-requests.
[INFO] Initializing environment for https://github.com/dosisod/refurb.
[INFO] Initializing environment for https://github.com/charliermarsh/ruff-pre-commit.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/psf/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/mirrors-mypy.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/dosisod/refurb.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/charliermarsh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
check for added large files..............................................Passed
check python ast.........................................................Passed
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check json...............................................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed
black....................................................................Passed
mypy.....................................................................Passed
refurb...................................................................Failed
- hook id: refurb
- exit code: 1
interpreted classes cannot inherit from compiled traits
ruff.....................................................................Passed
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1

Successful log (4 days ago)

$ pip install -U pip wheel setuptools pre-commit
Requirement already satisfied: pip in /usr/local/lib/python3.12/site-packages (23.2.1)
Collecting pip
  Obtaining dependency information for pip from https://files.pythonhosted.org/packages/47/6a/453160888fab7c6a432a6e25f8afe6256d0d9f2cbd25971021da6491d899/pip-23.3.1-py3-none-any.whl.metadata
  Downloading pip-23.3.1-py3-none-any.whl.metadata (3.5 kB)
Requirement already satisfied: wheel in /usr/local/lib/python3.12/site-packages (0.41.3)
Requirement already satisfied: setuptools in /usr/local/lib/python3.12/site-packages (68.2.2)
Collecting pre-commit
  Obtaining dependency information for pre-commit from https://files.pythonhosted.org/packages/6c/75/526915fedf462e05eeb1c75ceaf7e3f9cde7b5ce6f62740fe5f7f19a0050/pre_commit-3.5.0-py2.py3-none-any.whl.metadata
  Downloading pre_commit-3.5.0-py2.py3-none-any.whl.metadata (1.3 kB)
Collecting cfgv>=2.0.0 (from pre-commit)
  Obtaining dependency information for cfgv>=2.0.0 from https://files.pythonhosted.org/packages/c5/55/51844dd50c4fc7a33b653bfaba4c2456f06955289ca770a5dbd5fd267374/cfgv-3.4.0-py2.py3-none-any.whl.metadata
  Downloading cfgv-3.4.0-py2.py3-none-any.whl.metadata (8.5 kB)
Collecting identify>=1.0.0 (from pre-commit)
  Obtaining dependency information for identify>=1.0.0 from https://files.pythonhosted.org/packages/46/02/2581c37256119d65e6f1f47b62dd51dd3136d6b[20](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5495274980#L20)7bb49a8885a0d45c41a/identify-2.5.31-py2.py3-none-any.whl.metadata
  Downloading identify-2.5.31-py2.py3-none-any.whl.metadata (4.4 kB)
Collecting nodeenv>=0.11.1 (from pre-commit)
  Obtaining dependency information for nodeenv>=0.11.1 from https://files.pythonhosted.org/packages/1a/e6/6d2ead760a9ddb35e65740fd5a57e46aadd7b0c49861ab24f94812797a1c/nodeenv-1.8.0-py2.py3-none-any.whl.metadata
  Downloading nodeenv-1.8.0-py2.py3-none-any.whl.metadata ([21](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5495274980#L21) kB)
Collecting pyyaml>=5.1 (from pre-commit)
  Obtaining dependency information for pyyaml>=5.1 from https://files.pythonhosted.org/packages/b4/33/720548182ffa8344418126017aa1d4ab4aeec9a[22](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5495274980#L22)75f04ce3f3573d8ace8/PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Downloading PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
Collecting virtualenv>=20.10.0 (from pre-commit)
  Obtaining dependency information for virtualenv>=20.10.0 from https://files.pythonhosted.org/packages/7f/19/1f0eddcb9acf00a95793ce83417f69e0fd106c192121360af499cd6fde39/virtualenv-20.24.6-py3-none-any.whl.metadata
  Downloading virtualenv-20.24.6-py3-none-any.whl.metadata (4.5 kB)
Collecting distlib<1,>=0.3.7 (from virtualenv>=20.10.0->pre-commit)
  Obtaining dependency information for distlib<1,>=0.3.7 from https://files.pythonhosted.org/packages/43/a0/9ba967fdbd55293bacfc1507f58e316f740a3b[23](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5495274980#L23)1fc00e3d86dc39bc185a/distlib-0.3.7-py2.py3-none-any.whl.metadata
  Downloading distlib-0.3.7-py2.py3-none-any.whl.metadata (5.1 kB)
Collecting filelock<4,>=3.12.2 (from virtualenv>=20.10.0->pre-commit)
  Obtaining dependency information for filelock<4,>=3.12.2 from https://files.pythonhosted.org/packages/81/54/84d42a0bee35edba99dee7b59a8d4970eccdd44b99fe728ed912106fc781/filelock-3.13.1-py3-none-any.whl.metadata
  Downloading filelock-3.13.1-py3-none-any.whl.metadata (2.8 kB)
Collecting platformdirs<4,>=3.9.1 (from virtualenv>=20.10.0->pre-commit)
  Obtaining dependency information for platformdirs<4,>=3.9.1 from https://files.pythonhosted.org/packages/56/29/3ec311dc18804409ecf0d2b09caa976f3ae6215559306b5b530004e11156/platformdirs-3.11.0-py3-none-any.whl.metadata
  Downloading platformdirs-3.11.0-py3-none-any.whl.metadata (11 kB)
Downloading pip-23.3.1-py3-none-any.whl (2.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 26.4 MB/s eta 0:00:00
Downloading pre_commit-3.5.0-py2.py3-none-any.whl (203 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 203.7/203.7 kB 32.1 MB/s eta 0:00:00
Downloading cfgv-3.4.0-py2.py3-none-any.whl (7.2 kB)
Downloading identify-2.5.31-py2.py3-none-any.whl (98 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.9/98.9 kB 19.0 MB/s eta 0:00:00
Downloading nodeenv-1.8.0-py2.py3-none-any.whl (22 kB)
Downloading PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7[24](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5495274980#L24) kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7[25](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5495274980#L25).0/725.0 kB 74.0 MB/s eta 0:00:00
Downloading virtualenv-20.24.6-py3-none-any.whl (3.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.8/3.8 MB 103.1 MB/s eta 0:00:00
Downloading distlib-0.3.7-py2.py3-none-any.whl (468 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 kB 55.5 MB/s eta 0:00:00
Downloading filelock-3.13.1-py3-none-any.whl (11 kB)
Downloading platformdirs-3.11.0-py3-none-any.whl (17 kB)
Installing collected packages: distlib, pyyaml, platformdirs, pip, nodeenv, identify, filelock, cfgv, virtualenv, pre-commit
  Attempting uninstall: pip
    Found existing installation: pip 23.2.1
    Uninstalling pip-23.2.1:
      Successfully uninstalled pip-23.2.1
Successfully installed cfgv-3.4.0 distlib-0.3.7 filelock-3.13.1 identify-2.5.[31](https://gitlab.com/the-munchkins/self-paced-course/on-registration-send-invoice/-/jobs/5495274980#L31) nodeenv-1.8.0 pip-23.3.1 platformdirs-3.11.0 pre-commit-3.5.0 pyyaml-6.0.1 virtualenv-20.24.6
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
$ pre-commit install
pre-commit installed at .git/hooks/pre-commit
$ pre-commit run --all-files
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/psf/black.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-mypy.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-mypy:types-requests.
[INFO] Initializing environment for https://github.com/dosisod/refurb.
[INFO] Initializing environment for https://github.com/charliermarsh/ruff-pre-commit.
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/psf/black.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/mirrors-mypy.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/dosisod/refurb.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/charliermarsh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
check for added large files..............................................Passed
check python ast.........................................................Passed
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check json...............................................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed
black....................................................................Passed
mypy.....................................................................Passed
refurb...................................................................Passed
ruff.....................................................................Passed
Cleaning up project directory and file based variables
00:01
Job succeeded

Hope this can help... I have no clue what it could be.

@jamesbraza
Copy link
Author

jamesbraza commented Nov 13, 2023

@francesco086 for now, we need to add an additional_dependencies to pre-commit configs:

    - 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 mypy dependency range here could have mypy<1.7 for now: https://github.com/dosisod/refurb/blob/v1.22.2/pyproject.toml#L20

@francesco086
Copy link

@francesco086 you need to add an additional_dependencies for now:

Oh, got it! Many thanks! It works now :)

@dosisod
Copy link
Owner

dosisod commented Nov 13, 2023

@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).

@jamesbraza
Copy link
Author

Okay sounds good 👍.

In general, I am wondering if mypy minor version bumps have backwards compatible internals. It may make sense for refurb to always pin the minor version, and have some CI automation that, upon new mypy release, bumps the minor version if all tests pass. Tho that sounds like a pain in the butt to implement 😆

dosisod added a commit that referenced this issue Nov 13, 2023
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.
dosisod added a commit that referenced this issue Nov 13, 2023
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.
@dosisod
Copy link
Owner

dosisod commented Nov 13, 2023

Didn't mean to close this. I still consider this an issue, #306 is a bandaid fix until I find a better workaround.

@dosisod
Copy link
Owner

dosisod commented Nov 16, 2023

Closed by #309

@dosisod dosisod closed this as completed Nov 16, 2023
segsell added a commit to segsell/caregiving that referenced this issue Nov 20, 2023
@dosisod dosisod unpinned this issue Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mypy An upstream issue with Mypy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants