Skip to content

Commit

Permalink
rfctr(lint): tune in ruff settings
Browse files Browse the repository at this point in the history
  • Loading branch information
scanny committed Apr 29, 2024
1 parent 57d3b9e commit 630ecbf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Homepage = "https://github.com/python-openxml/python-docx"
Repository = "https://github.com/python-openxml/python-docx"

[tool.black]
line-length = 100
target-version = ["py37", "py38", "py39", "py310", "py311"]

[tool.pytest.ini_options]
Expand Down Expand Up @@ -69,6 +70,10 @@ python_functions = ["it_", "its_", "they_", "and_", "but_"]

[tool.ruff]
exclude = []
line-length = 100
target-version = "py38"

[tool.ruff.lint]
ignore = [
"COM812", # -- over-aggressively insists on trailing commas where not desired --
"PT001", # -- wants @pytest.fixture() instead of @pytest.fixture --
Expand All @@ -88,9 +93,8 @@ select = [
"UP032", # -- Use f-string instead of `.format()` call --
"UP034", # -- Avoid extraneous parentheses --
]
target-version = "py37"

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["docx"]
known-local-folder = ["helpers"]

Expand Down
6 changes: 1 addition & 5 deletions src/docx/image/tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ def _dpi(self, resolution_tag):
return 72

# resolution unit defaults to inches (2)
resolution_unit = (
ifd_entries[TIFF_TAG.RESOLUTION_UNIT]
if TIFF_TAG.RESOLUTION_UNIT in ifd_entries
else 2
)
resolution_unit = ifd_entries.get(TIFF_TAG.RESOLUTION_UNIT, 2)

if resolution_unit == 1: # aspect ratio only
return 72
Expand Down
6 changes: 2 additions & 4 deletions tests/unitutil/cxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def from_token(cls, token):
Return an ``Element`` object constructed from a parser element token.
"""
tagname = token.tagname
attrs = [(name, value) for name, value in token.attr_list]
attrs = [tuple(a) for a in token.attr_list]
text = token.text
return cls(tagname, attrs, text)

Expand Down Expand Up @@ -263,9 +263,7 @@ def grammar():
child_node_list << (open_paren + delimitedList(node) + close_paren | node)

root_node = (
element("element")
+ Group(Optional(slash + child_node_list))("child_node_list")
+ stringEnd
element("element") + Group(Optional(slash + child_node_list))("child_node_list") + stringEnd
).setParseAction(connect_root_node_children)

return root_node
Expand Down

0 comments on commit 630ecbf

Please sign in to comment.