Skip to content

pyrefly report counts aliases in multi-assignment expressions as untyped #3506

@jorenham

Description

@jorenham

PyZMQ (https://github.com/zeromq/pyzmq) has the following bit of code in zmq.utils.strtypes (src):

# give short 'b' alias for cast_bytes, so that we can use fake b'stuff'
# to simulate b'stuff'
b = asbytes = cast_bytes
u = cast_unicode

The aliased functions (cast_bytes and cast_unicode) are fully typed.

But pyrefly report lists these as follows:

{
  "kind": "attr",
  "name": "zmq.utils.strtypes.b",
  "n_typable": 1,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 1,
  "location": {
    "line": 52,
    "column": 1
  }
},
{
  "kind": "attr",
  "name": "zmq.utils.strtypes.asbytes",
  "n_typable": 1,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 1,
  "location": {
    "line": 52,
    "column": 5
  }
},
{
  "kind": "attr",
  "name": "zmq.utils.strtypes.u",
  "n_typable": 0,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 0,
  "location": {
    "line": 53,
    "column": 1
  }
},

For u it's not marked as typable (i.e. ignored), so that works as intended.

However, for the two-for-one alias (b = asbytes = cast_bytes), pyrefly reports both b and asbytes as typable (and untyped).

Metadata

Metadata

Assignees

No one assigned

    Labels

    quansightreportIssues related to `pyrefly report`

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions