Skip to content

Commit

Permalink
Convert directory fbcode/aml to use the Ruff Formatter
Browse files Browse the repository at this point in the history
Summary:
Converts the directory specified to use the Ruff formatter in pyfmt

ruff_dog

If this diff causes merge conflicts when rebasing, please run
`hg status -n -0 --change . -I '**/*.{py,pyi}' | xargs -0 arc pyfmt`
on your diff, and amend any changes before rebasing onto latest.
That should help reduce or eliminate any merge conflicts.

allow-large-files

Reviewed By: amyreese

Differential Revision: D64116946

fbshipit-source-id: c1414880ed8c6b458f096234ee30ccaaed217f10
  • Loading branch information
Thomas Polasek authored and facebook-github-bot committed Oct 9, 2024
1 parent 08d0a2e commit 1113b1d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
16 changes: 10 additions & 6 deletions augly/image/utils/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,16 @@ def transform_bboxes(
if dst_bboxes is None:
return

assert bbox_format is not None and bbox_format in [
"pascal_voc",
"pascal_voc_norm",
"coco",
"yolo",
], "bbox_format must be specified if bboxes are passed in and must be a supported format"
assert (
bbox_format is not None
and bbox_format
in [
"pascal_voc",
"pascal_voc_norm",
"coco",
"yolo",
]
), "bbox_format must be specified if bboxes are passed in and must be a supported format"

src_w, src_h = image.size
aug_w, aug_h = aug_image.size
Expand Down
6 changes: 3 additions & 3 deletions augly/text/augmenters/bidirectional.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
)


POP_DIRECTIONAL = "\u202C"
RTL_OVERRIDE = "\u202E"
LTR_OVERRIDE = "\u202D"
POP_DIRECTIONAL = "\u202c"
RTL_OVERRIDE = "\u202e"
LTR_OVERRIDE = "\u202d"


class BidirectionalAugmenter:
Expand Down
6 changes: 3 additions & 3 deletions augly/text/augmenters/insertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
# Not meant to be an exhaustive list
CHARACTER_TYPES = {
"zero_width": [
"\u200B", # Zero-Width Space
"\u200C", # Zero-Width Non-Joiner
"\u200D", # Zero-Width Joiner
"\u200b", # Zero-Width Space
"\u200c", # Zero-Width Non-Joiner
"\u200d", # Zero-Width Joiner
"\u2060", # Word Joiner
"\u2061", # Function Application
"\u2062", # Invisible Times
Expand Down
2 changes: 1 addition & 1 deletion augly/video/augmenters/cv2/base_augmenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def moving_origins(

@staticmethod
def random_colors(
colors: Optional[List[Tuple[int, int, int]]]
colors: Optional[List[Tuple[int, int, int]]],
) -> Iterator[Tuple[int, int, int]]:
if colors is not None:
assert type(colors) == list, "Expected type 'List' for colors variable"
Expand Down
19 changes: 11 additions & 8 deletions augly/video/augmenters/cv2/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,19 @@ def __init__(
assert (
text_change_nth is None or text_change_nth > 0
), "`text_change_nth` must be greater than zero"
assert fonts is None or all(
(isinstance(font, (str, ImageFont.ImageFont)) or (font in CV2_FONTS))
and (chars is None or isinstance(chars, str))
for font, chars in fonts
assert (
fonts is None
or all(
(isinstance(font, (str, ImageFont.ImageFont)) or (font in CV2_FONTS))
and (chars is None or isinstance(chars, str))
for font, chars in fonts
)
), "Fonts must be either None or a list of tuples of font (cv2 font, PIL ImageFont, or str path to a .ttf file) & chars file (str path or None)"
assert fontscales is None or (
fontscales[0] > 0 and fontscales[1] > fontscales[0]
assert (
fontscales is None or (fontscales[0] > 0 and fontscales[1] > fontscales[0])
), "Fontscale ranges must be greater than zero and the second value must be greater than the first" # noqa: B950
assert thickness is None or (
type(thickness) == int and thickness > 0
assert (
thickness is None or (type(thickness) == int and thickness > 0)
), "Invalid thickness provided: must be set to None or be an integer greater than zero" # noqa: B950

super().__init__(1, random_movement, topleft, bottomright, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions augly/video/helpers/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def compute_insert_in_background_multiple_segments(
assert n == len(
src_segment_ends
), "Source segment starts and ends lists must have equal length."
assert n == len(
bkg_insertion_points
assert (
n == len(bkg_insertion_points)
), "Source segment starts and background insertion points lists must have equal length."
assert n == len(
src_ids
Expand Down

0 comments on commit 1113b1d

Please sign in to comment.