Skip to content

pyrefly report includes if __name__ == "__main__" declarations #3624

@jorenham

Description

@jorenham

For example, in NumPy, for numpy/f2py/crackfortran.py, which starts as

if __name__ == "__main__":
    files = []
    funcs = []
    f = 1
    f2 = 0
    f3 = 0
    showblocklist = 0
    # --snip--

(src)

is reported by pyrefly coverage report as

{
  "kind": "attr",
  "name": "numpy.f2py.crackfortran.files",
  "n_typable": 0,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 0,
  "location": {
    "line": 3655,
    "column": 5
  }
},
{
  "kind": "attr",
  "name": "numpy.f2py.crackfortran.funcs",
  "n_typable": 0,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 0,
  "location": {
    "line": 3656,
    "column": 5
  }
},
{
  "kind": "attr",
  "name": "numpy.f2py.crackfortran.f",
  "n_typable": 1,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 1,
  "location": {
    "line": 3657,
    "column": 5
  }
},
{
  "kind": "attr",
  "name": "numpy.f2py.crackfortran.f2",
  "n_typable": 1,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 1,
  "location": {
    "line": 3658,
    "column": 5
  }
},
{
  "kind": "attr",
  "name": "numpy.f2py.crackfortran.f3",
  "n_typable": 1,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 1,
  "location": {
    "line": 3659,
    "column": 5
  }
},
{
  "kind": "attr",
  "name": "numpy.f2py.crackfortran.showblocklist",
  "n_typable": 1,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 1,
  "location": {
    "line": 3660,
    "column": 5
  }
},
{
  "kind": "attr",
  "name": "numpy.f2py.crackfortran.l",
  "n_typable": 1,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 1,
  "location": {
    "line": 3661,
    "column": 9
  }
},
{
  "kind": "attr",
  "name": "numpy.f2py.crackfortran.detail",
  "n_typable": 1,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 1,
  "location": {
    "line": 3707,
    "column": 31
  }
},
{
  "kind": "attr",
  "name": "numpy.f2py.crackfortran.postlist",
  "n_typable": 1,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 1,
  "location": {
    "line": 3720,
    "column": 5
  }
},
{
  "kind": "attr",
  "name": "numpy.f2py.crackfortran.pyf",
  "n_typable": 1,
  "n_typed": 0,
  "n_any": 0,
  "n_untyped": 1,
  "location": {
    "line": 3723,
    "column": 9
  }
},

Admittedly it's probably better if this would've been scoped in a helper function. But even so, I don't think that pyrefly coverage report should've included this.

Related to #3404.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions