Fixing the Formatting of the bitCountByte Variable: pymysqlreplication/bitmap.py#540
Conversation
| 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, | ||
| 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, | ||
| 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, | ||
| 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, |
There was a problem hiding this comment.
We need to write #fmt on
Avoid black convention
And can you change title kor to eng?
|
I've improved readability by breaking the bitCountByte variable into lines, with 16 items per line. |
- black does not provide a way to ignore by convention - ignore by specifying file name
|
if you want to do this you have to fix this code like this # fmt: off
bitCountInByte = [
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
]
# fmt: onand how about changing variable name instead of applying formatting which I have done eariler https://github.com/julien-duponchelle/python-mysql-replication/pull/518/files |
|
I believe it would be beneficial to address all modifications related to 'bitmap.py' in this pull request at once. It would be a good idea to convert variables and functions written in camelCase, such as 'bitCountInByte,' to snake_case to adhere to the PEP 8 convention. |
|
|
||
| ruff pymysqlreplication | ||
| black pymysqlreplication --check | ||
| black pymysqlreplication --exclude pymysqlreplication/bitmap.py --check |
There was a problem hiding this comment.
not exclude all bitmap.py
apply # fmt: on is more better
There was a problem hiding this comment.
I think it would be helpful if you refer to this document
It doesn’t reformat lines that end with # fmt: skip or blocks that start with # fmt: off and end with # fmt: on. # fmt: on/off must be on the same level of indentation and in the same block, meaning no unindents beyond the initial indentation level between them.
I agree that this is a better solution, because it leaves the rest of codes subject to the lint test. |
maybe if we seperate bitCountByte into another independent file and exclude from linting. It can be a solution |
I looooovvveee your solution. |
can we find out varables and enums together? |
|
This is an alternative to a lookup list. def bit_count(n):
return bin(n).count('1')This is more readable and I would say more Pythonic too (but not in a strict sense). I'll do some research on other projects that emulate RDBMS and see how they implemented. |
I've improved readability by breaking the bitCountByte variable into lines, with 16 items per line.
close #539