Skip to content

strict_optional=False makes checking scripts using xarray to fail #9437

@dalonsoa

Description

@dalonsoa

🐛 Bug Report

When using mypy with strict_optional = False in the config file or using the --no-strict-optional flag in the terminal to check a file using the xarray package, it fails with an scary INTERNAL ERROR message.

This might be a bug better suited for the xarray team, but thought to check with you first.

To Reproduce

Write a python script just importing xarray:

import xarray as xr

And check it with mypy using mypy --no-strict-optional script.py

Expected Behavior

Everything works fine and I get: Success: no issues found in 1 source file . This is indeed the behavior if the --no-strict-optional flag is NOT used.

Actual Behavior

I get the following output (personal info replaced by XXXXX):

/XXXXX/venv/lib/python3.7/site-packages/xarray/core/dataarray.py:2001: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
If this issue continues with mypy master, please report a bug at https://github.com/python/mypy/issues
version: 0.782
/XXXXX/venv/lib/python3.7/site-packages/xarray/core/dataarray.py:2001: : note: please use --show-traceback to print a traceback when reporting a bug

I've tried also the development version of mypy, as sugested, with identical results, and also used the --show-traceback option, with results in:

/XXXXX/venv/lib/python3.7/site-packages/xarray/core/dataarray.py:2001: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.782
Traceback (most recent call last):
  File "mypy/checker.py", line 401, in accept
  File "mypy/nodes.py", line 1129, in accept
  File "mypy/checker.py", line 3437, in visit_for_stmt
  File "mypy/checker.py", line 3470, in analyze_iterable_item_type
  File "mypy/checkexpr.py", line 2345, in check_method_call_by_name
  File "mypy/checkmember.py", line 126, in analyze_member_access
  File "mypy/checkmember.py", line 143, in _analyze_member_access
  File "mypy/checkmember.py", line 225, in analyze_instance_member_access
  File "mypy/checkmember.py", line 376, in analyze_member_var_access
  File "mypy/checkmember.py", line 578, in analyze_var
  File "mypy/meet.py", line 50, in meet_types
  File "mypy/types.py", line 794, in accept
  File "mypy/meet.py", line 497, in visit_instance
  File "mypy/meet.py", line 647, in meet
  File "mypy/meet.py", line 50, in meet_types
  File "mypy/types.py", line 1347, in accept
  File "mypy/meet.py", line 584, in visit_tuple_type
  File "mypy/typeops.py", line 44, in tuple_fallback
  File "mypy/join.py", line 531, in join_type_list
  File "mypy/join.py", line 105, in join_types
  File "mypy/types.py", line 794, in accept
  File "mypy/join.py", line 158, in visit_instance
  File "mypy/join.py", line 371, in join_instances
  File "mypy/subtypes.py", line 143, in is_subtype_ignoring_tvars
  File "mypy/subtypes.py", line 93, in is_subtype
  File "mypy/subtypes.py", line 135, in _is_subtype
  File "mypy/types.py", line 794, in accept
  File "mypy/subtypes.py", line 259, in visit_instance
  File "mypy/subtypes.py", line 541, in is_protocol_implementation
  File "mypy/subtypes.py", line 93, in is_subtype
  File "mypy/subtypes.py", line 135, in _is_subtype
  File "mypy/types.py", line 1786, in accept
  File "mypy/subtypes.py", line 459, in visit_partial_type
RuntimeError: 
/XXXXX/venv/lib/python3.7/site-packages/xarray/core/dataarray.py:2001: : note: use --pdb to drop into pdb

Your Environment

  • Mypy version used: 0.782
  • xarray version: 0.16.0
  • Mypy command-line flags: --no-strict-optional
  • Mypy configuration options from mypy.ini (and other config files): strict_optional = False has the same effect.
  • Python version used: 3.7.4
  • Operating system and version: Mac OS Catalina 10.15.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy