Skip to content

Commit

Permalink
Last tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
nachovizzo committed Jul 29, 2024
1 parent d764759 commit 58b7d81
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ament_black/ament_black/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ def main(argv=sys.argv[1:]):
return 1

# TODO(Nacho): Inject the config file results into the ctx (use read_pyproject_toml)
BLACK_VERSION = metadata.version('black')
BLACK_OLD_GET_SOURCES_API = Version(BLACK_VERSION) < Version('23.9.0')
if BLACK_OLD_GET_SOURCES_API:
BLACK_VERSION = Version(metadata.version('black'))
if BLACK_VERSION < Version('23.9.0'):
sources = get_sources(
ctx=click.Context(black),
src=tuple(args.paths),
Expand All @@ -96,7 +95,10 @@ def main(argv=sys.argv[1:]):
stdin_filename='',
)
else:
# Hack to support newer versions of black in ROS Jazzy
# https://github.com/botsandus/ament_black/issues/12
from black import find_project_root

sources = get_sources(
root=find_project_root(tuple(args.paths))[0],
src=tuple(args.paths),
Expand Down

0 comments on commit 58b7d81

Please sign in to comment.