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

Script for merging stubs into Django source files for testing #408

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Script for merging stubs into Django source files for testing #408

wants to merge 12 commits into from

Conversation

kszmigiel
Copy link
Member

@kszmigiel
Copy link
Member Author

@mkurnikov @sobolevn I had not much time to sink into libcst docs yet, so here's just initial version on the script, so you can easily check my progress on this in the nearest future :)

@mkurnikov
Copy link
Member

Looks about right. Now we need to add more steps:

  1. Merge all the stubs into Django sources. This will probably create lots of edge cases, at least that how it was with my experiments with retype from before.
  2. Run mypy on top of annotated Django sources. We can start with whitelisting files to check.
  3. Community call for help, probably. Add it to CI to prevent regressions.

context = CodemodContext()
visitor = ApplyTypeAnnotationsVisitor(context)

stubs_dir = '../django-stubs'
Copy link
Member

Choose a reason for hiding this comment

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

Please, make paths not .. relative, but with Path(__file__).parent so that script could be run from other directories too.

for path in stubs_pathlist:
str_path = str(path)

stubs_dict[str_path.split('/', 2)[-1].split('.')[0]] = str_path
Copy link
Member

Choose a reason for hiding this comment

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

Same thing here, use pathlib.Path everywhere for filesystem paths.

if key in stubs_dict:
sources_dict[key] = str_path

for key in stubs_dict:
Copy link
Member

Choose a reason for hiding this comment

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

Please use enumerate(stubs_dict), you're using values of the dict too

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

Successfully merging this pull request may close these issues.

Testing stubs against Django source code
2 participants