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

Allow user to specify custom typeshed directory #1588

Merged
merged 6 commits into from
Oct 25, 2016

Conversation

ddfisher
Copy link
Collaborator

This avoids doing any sort of cleanup of default_data_dir to be as safe of a change as possible.

Triggers #1587 and therefore blocks on it.

@ddfisher ddfisher force-pushed the PR/typeshed-flag branch from a197a66 to e26052f Compare May 27, 2016 00:14
@@ -160,6 +162,8 @@ def parse_version(v):
help="an anti-pattern")
parser.add_argument('--stats', action='store_true', help="dump stats")
parser.add_argument('--inferstats', action='store_true', help="dump type inference stats")
parser.add_argument('--custom-typeshed', metavar='PATH',
help="use the custom typeshed module at PATH")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if the term 'typeshed module' is clear enough, as the term 'module' is overloaded? Maybe use 'typeshed repository'?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What about "typeshed package"?

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 17, 2016

Looks good, other the note above about the help message.

@gvanrossum
Copy link
Member

It's neither a package nor a module -- it's a directory though.

Maybe now that you've redone the command line options you can rebase, rework, and resubmit this? I still think it's a great idea. (Maybe also add to the docs? There's an extensive chapter on the command line.)

@ddfisher ddfisher force-pushed the PR/typeshed-flag branch from e26052f to 289f643 Compare July 8, 2016 01:00
@ddfisher
Copy link
Collaborator Author

ddfisher commented Jul 8, 2016

I think this is blocking on #1587 now.

@gvanrossum gvanrossum changed the title Allow user to specify custom typeshed directory [conflict] [WIP] Allow user to specify custom typeshed directory Sep 29, 2016
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

It's a shame that this is blocked for that silly partial bug #1587... If you can work around that this can be committed after rebasing.

options.custom_typeshed_dir.rstrip(os.sep))
data_dir = custom_data_dir
else:
data_dir = default_data_dir(bin_dir)
Copy link
Member

Choose a reason for hiding this comment

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

Can you work around #1587 by setting custom_typeshed_name = None here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, that fixes it!

@ddfisher ddfisher changed the title [conflict] [WIP] Allow user to specify custom typeshed directory Allow user to specify custom typeshed directory Oct 17, 2016
@ddfisher
Copy link
Collaborator Author

Updated! Should be mergeable now.

@gvanrossum
Copy link
Member

PS can you try not to squash all local commits?

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

(Funny, I thought I submitted these. Sorry.)

@@ -326,6 +326,12 @@ Here are some more useful flags:
package, the behavior enabled by this flag is often more
convenient.)

- ``--custom-typeshed-dir DIR`` specifies the directory where mypy looks for
Copy link
Member

Choose a reason for hiding this comment

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

Can you also update config_file.rst?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍

options.custom_typeshed_dir.rstrip(os.sep))
data_dir = custom_data_dir
else:
custom_typeshed_name = None
Copy link
Member

Choose a reason for hiding this comment

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

Or maybe 'typeshed' so you won't have to fill that in later? (Then perhaps drop the 'custom_' prefix.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that's nicer. Changed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, this got changed in a different way from the refactor to fix the other issues.

@@ -266,7 +277,7 @@ def default_lib_path(data_dir: str, pyversion: Tuple[int, int]) -> List[str]:
# (Note that 3.1 and 3.0 aren't really supported, but we don't care.)
for v in versions + [str(pyversion[0]), '2and3']:
for lib_type in ['stdlib', 'third_party']:
stubdir = os.path.join(data_dir, 'typeshed', lib_type, v)
stubdir = os.path.join(data_dir, typeshed_name, lib_type, v)
Copy link
Member

Choose a reason for hiding this comment

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

It's somewhat perverse that the flag first gets separated into a data_dir and a typeshed_name and then they are joined again here. And don't the other uses of data_dir care that it's been overridden? (It's passed to Reports() which uses it to locate some style sheets.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refactored.

"""Return default standard library search paths."""
# IDEA: Make this more portable.
path = [] # type: List[str]
typeshed_name = custom_typeshed_name or 'typeshed'

auto = os.path.join(data_dir, 'stubs-auto')
Copy link
Member

Choose a reason for hiding this comment

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

This block (three lines starting here) probably has to be skipped if a custom typeshed was given.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What's going on here? What is stubs-auto? (The commit that introduces it doesn't explain at all...)

@@ -188,6 +188,8 @@ def process_options(args: List[str],
help="dump type inference stats")
parser.add_argument('--custom-typing', metavar='MODULE', dest='custom_typing_module',
help="use a custom typing module")
parser.add_argument('--custom-typeshed-dir', metavar='DIR',
help="use the custom typeshed in DIR")
Copy link
Member

Choose a reason for hiding this comment

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

I think Jukka had suggested to change this to "custom typeshed package in DIR" ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looking through the old comments, we noted that typeshed wasn't really a package -- that's why I left that out here.

@ddfisher
Copy link
Collaborator Author

@gvanrossum can you take another look at this?

@codecov-io
Copy link

codecov-io commented Oct 25, 2016

Current coverage is 83.48% (diff: 66.66%)

Merging #1588 into master will decrease coverage by <.01%

@@             master      #1588   diff @@
==========================================
  Files            72         72          
  Lines         19012      19017     +5   
  Methods           0          0          
  Messages          0          0          
  Branches       3931       3932     +1   
==========================================
+ Hits          15873      15876     +3   
- Misses         2542       2543     +1   
- Partials        597        598     +1   

Powered by Codecov. Last update d0ea126...3ca9253

@gvanrossum gvanrossum merged commit b8aa01b into python:master Oct 25, 2016
@ddfisher ddfisher deleted the PR/typeshed-flag branch October 25, 2016 23:16
@ddfisher
Copy link
Collaborator Author

🎉

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.

4 participants