Skip to content

Use str.splitlines() to split lines - #33592

Merged
Taragolis merged 1 commit into
apache:mainfrom
eumiro:splitlines
Aug 24, 2023
Merged

Use str.splitlines() to split lines#33592
Taragolis merged 1 commit into
apache:mainfrom
eumiro:splitlines

Conversation

@eumiro

Copy link
Copy Markdown
Contributor

No description provided.

@amoghrajeshamoghrajesh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes look good but the CI is failing with the error:

dev/prepare_release_issue.py:304: error:
"Callable[[str, str, SupportsIndex], str]" has no attribute "splitlines" [attr-defined]
body = " ".join(pr.body.replace.splitlines())
^~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 117 source files)

Have you installed the pre commit? Makes it easier to track static checks..

@eumiro

Copy link
Copy Markdown
ContributorAuthor

@amoghrajesh thanks, I have it installed, but for some reason disabled yesterday. Now it is fixed.

Comment threadairflow/utils/file.py Outdated

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 would keep the with open style and rewrite the reading part to

[re2.sub(r"\s*#.*", "", line) forlineinifile]

This would allow the input to be read line by line instead of creating a temporary string before splitting.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

How about

ignore_file_path=Path(root) /ignore_file_nameifignore_file_path.is_file():
uniq_patterns= {}
withignore_file_path.open() asf:
forlineinf:
line=line.strip()
iflineandnotline.startswith("#"):
pattern=ignore_rule_type.compile(line, Path(base_dir_path), ignore_file_path)
ifpattern:
uniq_patterns[pattern] =None# evaluation order of patterns is important with negation# so that later patterns can override earlier patternspatterns=list(uniq_patterns)

This probably describes the steps even better, and shows that the ignore_rule_type.compile is called before the patterns are filtered via uniq (dict).

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.

Yeah I wouldn’t object.

@eumiro
eumiroforce-pushed the splitlines branch 2 times, most recently from b81230b to 981d9a6CompareAugust 24, 2023 18:19
@Taragolis
Taragolis merged commit 0e00564 into apache:mainAug 24, 2023
@ephraimbuddyephraimbuddy added this to the Airflow 2.7.2 milestone Oct 3, 2023
@ephraimbuddyephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Oct 3, 2023
ephraimbuddy pushed a commit that referenced this pull request Oct 5, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:CLIarea:dev-toolskind:documentationprovider:cncf-kubernetesKubernetes (k8s) provider related issuestype:misc/internalChangelog: Misc changes that should appear in change log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@eumiro@potiuk@uranusjr@amoghrajesh@Taragolis@ephraimbuddy