Skip to content

Allow user to specify custom typeshed directory - #1588

Merged
gvanrossum merged 6 commits into
python:masterfrom
ddfisher:PR/typeshed-flag
Oct 25, 2016
Merged

gvanrossum merged 6 commits into
python:masterfrom
ddfisher:PR/typeshed-flag

Conversation

@ddfisher

Copy link
Copy Markdown
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
Comment thread mypy/main.py Outdated
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
Copy Markdown
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
Copy Markdown
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

JukkaL commented Jun 17, 2016

Copy link
Copy Markdown
Collaborator

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

@gvanrossum

Copy link
Copy Markdown
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

ddfisher commented Jul 8, 2016

Copy link
Copy Markdown
Collaborator Author

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

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

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.

Comment thread mypy/build.py Outdated
options.custom_typeshed_dir.rstrip(os.sep))
data_dir = custom_data_dir
else:
data_dir = default_data_dir(bin_dir)

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator Author

Updated! Should be mergeable now.

@gvanrossum

Copy link
Copy Markdown
Member

PS can you try not to squash all local commits?

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

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.)

package, the behavior enabled by this flag is often more
convenient.)

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

Copy link
Copy Markdown
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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

👍

Comment thread mypy/build.py Outdated
options.custom_typeshed_dir.rstrip(os.sep))
data_dir = custom_data_dir
else:
custom_typeshed_name = None

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread mypy/build.py Outdated
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
Copy Markdown
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
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Refactored.

Comment thread mypy/build.py Outdated
path = [] # type: List[str]
typeshed_name = custom_typeshed_name or 'typeshed'

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

Copy link
Copy Markdown
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
Copy Markdown
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...)

Comment thread mypy/main.py
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Collaborator Author

@gvanrossum can you take another look at this?

@codecov-io

codecov-io commented Oct 25, 2016 •

Copy link
Copy Markdown

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
Copy Markdown
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