Skip to content

Commit

Permalink
Output python version and implementation as part of --version flag (#…
Browse files Browse the repository at this point in the history
…2997)

Example:

black, 22.1.1.dev56+g421383d.d20220405 (compiled: no)
Python (CPython) 3.9.12

Co-authored-by: Batuhan Taskaya <isidentical@gmail.com>
  • Loading branch information
jpy-git and isidentical committed Apr 6, 2022
1 parent 9b30740 commit f6188ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -37,6 +37,8 @@

<!-- Changes to Black's terminal output and error messages -->

- Output python version and implementation as part of `--version` flag (#2997)

### Packaging

<!-- Changes to how Black is packaged, such as dependency requirements -->
Expand Down
6 changes: 5 additions & 1 deletion src/black/__init__.py
Expand Up @@ -10,6 +10,7 @@
import os
from pathlib import Path
from pathspec.patterns.gitwildmatch import GitWildMatchPatternError
import platform
import re
import signal
import sys
Expand Down Expand Up @@ -381,7 +382,10 @@ def validate_regex(
)
@click.version_option(
version=__version__,
message=f"%(prog)s, %(version)s (compiled: {'yes' if COMPILED else 'no'})",
message=(
f"%(prog)s, %(version)s (compiled: {'yes' if COMPILED else 'no'})\n"
f"Python ({platform.python_implementation()}) {platform.python_version()}"
),
)
@click.argument(
"src",
Expand Down

0 comments on commit f6188ce

Please sign in to comment.