-
Notifications
You must be signed in to change notification settings - Fork 68
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
style(black): format acquisition with black
, line-length=100
#1189
Conversation
sql = ( | ||
f"INSERT INTO `{self.table_name}` (`id`, `{self.publication_col_name}`, {columns}) " | ||
f"VALUES ({value_placeholders})" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more vertical space waste
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disagree; in this case highlighting INSERT INTO and VALUES improves scan-ability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separating those two was already in the original code though. black added the parentheses, doubling the the vertical space of this code :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this one a lot better than with line-length=200
. The formatting is acceptable overall and the wrapping style is more readable.
It's not 100% ideal in several places, but there are too many changes here to futz around with manually fixing and freezing more than a few individual lines.
I'd say the most worthwhile use of time would be deciding how we want to format the Columndef("previous_day_admission_adult_covid_confirmed_20-29_7_day_sum", "previous_day_admission_adult_covid_confirmed_20_29_7_day_sum", int),
lines in all the database.py
variants, and call it good after that.
if logger and len(dfs) > 7: | ||
logger.warning( | ||
"expensive operation", | ||
msg="concatenating more than 7 files may result in long running times", | ||
count=len(dfs), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better in this version
"REGION TYPE", | ||
"REGION", | ||
"YEAR", | ||
"WEEK", | ||
"TOTAL SPECIMENS", | ||
"TOTAL A", | ||
"TOTAL B", | ||
"PERCENT POSITIVE", | ||
"PERCENT A", | ||
"PERCENT B", | ||
]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better wrapping here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? I don't notice a change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the ambiguity, I was comparing to the line-length: 200
behavior here. Some other comments in this review are also discussing changes compared to the length-200 version, rather than the before-and-after here.
'--test', | ||
action='store_true', | ||
help='do dry run only, do not update the database' | ||
"--test", action="store_true", help="do dry run only, do not update the database" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same with the vertical space comment
args = [ | ||
row["total_specimens"], | ||
row["total_a"], | ||
row["total_b"], | ||
row["percent_positive"], | ||
row["percent_a"], | ||
row["percent_b"], | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not the best use of space but acceptable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i prefer it
Absolutely agree with your review comment. Formatting ColumnDef lines is actually moot, since we have a refactor that removes those lines already. So I'm just going to exclude covid_hosp from this PR, to avoid conflicts with that PR. We can format that code after those refactors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Places it falls over:
- repeated calls should use the same wrap mode
- same-line comments on too-long lines should be moved to the previous line before applying wrapping rules
otherwise seems pretty good!
zip_path = f"{DELPHI_BASE_DIR}/dropbox_{timestamp}.zip" | ||
print(f"downloading into delphi:{zip_path}") | ||
with ZipFile(zip_path, "w", ZIP_DEFLATED) as zf: | ||
for name in save_list: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is when I wish github let you provide manual alignment markers to make diffs make sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you do "hide whitespace" up in the gear above, it makes these diffs way more readable
sql = ( | ||
f"INSERT INTO `{self.table_name}` (`id`, `{self.publication_col_name}`, {columns}) " | ||
f"VALUES ({value_placeholders})" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disagree; in this case highlighting INSERT INTO and VALUES improves scan-ability
"--test", action="store_true", help="do dry run only, do not update the database" | ||
) | ||
parser.add_argument( | ||
"--file", type=str, help="load an existing zip file (otherwise fetch current data)" | ||
) | ||
parser.add_argument( | ||
"--issue", type=int, help="issue of the file (e.g. 201740); used iff --file is given" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmmm I'm skeptical about these. if it were just one, fine, but with three of them it's helpful to have whitespace highlight argument alignment
"REGION TYPE", | ||
"REGION", | ||
"YEAR", | ||
"WEEK", | ||
"TOTAL SPECIMENS", | ||
"TOTAL A", | ||
"TOTAL B", | ||
"PERCENT POSITIVE", | ||
"PERCENT A", | ||
"PERCENT B", | ||
]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? I don't notice a change
Trying to test and fix the regex in question that SonarCloud doesn't like, but the norostat code doesn't even seem to be run correctly. It breaks in line 74 of that same file, where the output of |
black
line-length=100
black
, line-length=100
we're still running a norostat cronicle job daily, but it's been failing since November 2020. Checking with R&R whether to keep it or not. |
Dropped Norostat changes from this and changed the base to the no-Norostat PR |
Co-authored-by: Katie Mazaitis <[email protected]>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
thanks for fixing all the fmt: on|off
cases!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
A version of #1186 with black's
line-length=100
. Recommend using GitHub's ignore whitespace feature when looking at diffs.TL;DR: it mostly looks good. The main jank is, as Katie put it below, "repeated calls should use the same wrap mode".
pip install flynt
andflynt src/acquisition -a -l 999 --verbose
(-a is aggressive, it won't change % strings otherwise, -l 999 is line-length, it won't change long strings otherwise, --verbose is to have it log its changes). With this, it had a 94/98 success rate on %-style expressions, so I had to go fix a few manually.