Skip to content

Conversation

Dr-Irv
Copy link
Collaborator

@Dr-Irv Dr-Irv commented Oct 3, 2025

There were 9 places where reportMissingTypeStubs came up, so this PR makes that issue go away

@Dr-Irv Dr-Irv requested a review from cmp0xff October 3, 2025 18:02
@cmp0xff
Copy link
Contributor

cmp0xff commented Oct 3, 2025

/pyright_strict

Copy link
Contributor

@cmp0xff cmp0xff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions and comments.

@Dr-Irv Dr-Irv requested a review from cmp0xff October 3, 2025 22:24
@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented Oct 3, 2025

FYI @cmp0xff A good thing to note. If pyright is working, and mypy is reporting Any, check the stubs and make sure that __init__.pyi is there along the import chain within each submodule. That took me a while to figure out this time, and I remember having to deal with this a few years ago.

@cmp0xff
Copy link
Contributor

cmp0xff commented Oct 3, 2025

/pyright_strict

Copy link
Contributor

@cmp0xff cmp0xff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Dr-Irv !

@cmp0xff cmp0xff merged commit 6ce988b into pandas-dev:main Oct 4, 2025
13 of 14 checks passed
@cmp0xff
Copy link
Contributor

cmp0xff commented Oct 4, 2025

I asked GitHub copilot to make a shell script to create __init__.pyi for me recursively. There is no more missing __init__.pyi in the stubs.

#!/usr/bin/env bash
# Minimalist helpers for creating __init__.pyi files
# - subdirs DIR -> prints direct subdirectories (one per line)
# - ensure_init FILE -> creates FILE if missing (empty)
# - mkinit_pyi_recursive DIR -> ensures __init__.pyi in DIR and all subdirs

set -eu

# List direct subdirectories of a directory, robust with spaces/newlines
subdirs() {
  local dir=${1:-.}
  # use find with -mindepth 1 -maxdepth 1 -type d and print0 to handle names safely
  find "$dir" -mindepth 1 -maxdepth 1 -type d -print0 | while IFS= read -r -d '' d; do
    printf '%s\n' "$d"
  done
}

# Create __init__.pyi if it doesn't exist
ensure_init() {
  local f=$1
  if [ ! -e "$f" ]; then
    : > "$f"
  fi
}

# Recursively create __init__.pyi in DIR and its direct subdirectories (depth-first)
mkinit_pyi_recursive() {
  local dir=${1:-.}
  printf '%s\n' "$dir"
  # ensure the init file in this dir
  ensure_init "$dir/__init__.pyi"
  # iterate direct subdirectories
  subdirs "$dir" | while IFS= read -r sub; do
    mkinit_pyi_recursive "$sub"
  done
}

# If the script is invoked, run the recursive function on given path(s)
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
  if [ $# -eq 0 ]; then
    mkinit_pyi_recursive .
  else
    for p in "$@"; do
      mkinit_pyi_recursive "$p"
    done
  fi
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants