Skip to content

Adds --output-dir option to stubgen #3902

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

Merged

Conversation

brianbruggeman
Copy link
Contributor

@brianbruggeman brianbruggeman commented Aug 31, 2017

Currently, the output folder is hard-coded.

  • Adds an option (--output-dir) to the stubgen command-line interface
    -- allows user to provide a different output folder other than 'out'
    -- defaults to 'out'
    -- allows ~user and relative '.' paths

  • Now creates a new folder if it doesn't already exist

@brianbruggeman brianbruggeman force-pushed the add-output-dir-option-to-stubgen branch from 51441af to 3c76fa7 Compare August 31, 2017 18:17
@gvanrossum
Copy link
Member

The default should really remain 'out'.

@brianbruggeman
Copy link
Contributor Author

Is there a reason/backstory on why out is currently hard-coded?

@brianbruggeman brianbruggeman force-pushed the add-output-dir-option-to-stubgen branch 3 times, most recently from 9a2a246 to ca2576f Compare August 31, 2017 21:15
@gvanrossum
Copy link
Member

why out is currently hard-coded?

This makes it clear what the output is from the script and makes it easy to throw it away if you prefer to start over.

mypy/stubgen.py Outdated
args = args[1:]
# Resolve/expand output_dir; use symlinks
if output_dir.startswith('~'):
output_dir = os.path.expanduser(output_dir)
Copy link
Member

Choose a reason for hiding this comment

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

Normally the shell takes care of this. I think on Windows it may not -- but is it really important enough to support?

mypy/stubgen.py Outdated
if output_dir.startswith('~'):
output_dir = os.path.expanduser(output_dir)
elif output_dir == '.':
output_dir = os.getenv('PWD') or os.getcwd()
Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose of this? I don't believe stubgen ever changes the current directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are completely unnecessary.

mypy/stubgen.py Outdated
elif output_dir == '.':
output_dir = os.getenv('PWD') or os.getcwd()
else:
output_dir = os.path.abspath(output_dir)
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

mypy/stubgen.py Outdated
@@ -697,6 +712,9 @@ def parse_options(args: List[str]) -> Options:
usage()
if not interpreter:
interpreter = sys.executable if pyversion[0] == 3 else default_python2_interpreter()
# Build the output folder if it doesn't already exist.
Copy link
Member

Choose a reason for hiding this comment

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

Build -> Create

* Adds an option (--output-dir) to the stubgen command-line interface
  -- allows user to provide a different output folder other than 'out'
  -- defaults to out
  -- allows ~user and relative '.' paths
  -- Adds help documentation and updates --output-dir to -o
@brianbruggeman brianbruggeman force-pushed the add-output-dir-option-to-stubgen branch from ca2576f to 99adac9 Compare September 20, 2017 20:38
@gvanrossum gvanrossum merged commit 8b43e15 into python:master Sep 20, 2017
@gvanrossum
Copy link
Member

Thanks!

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