Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ repos:
- --autofix
- --no-ensure-ascii
- id: trailing-whitespace
exclude: "^rfc/.*[.]txt$|^tests/tc2231/tc2231.html$"
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand All @@ -24,7 +25,7 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.14
rev: v0.15.21
hooks:
- id: ruff-check
alias: "ruff"
Expand Down Expand Up @@ -54,7 +55,7 @@ repos:
stages: [commit-msg]
args: ["--strict"]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v2.1.0
rev: v2.2.0
hooks:
- id: mypy
stages: [manual]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ HTTP and extensions are defined in the following RFC's:

* JavaScript Object Notation (JSON) Patch ([RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902))

* The HTTP QUERY Method ([RFC 10008](https://datatracker.ietf.org/doc/html/rfc10008))

* Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP) ([RFC 6266](https://datatracker.ietf.org/doc/html/rfc6266))

* Upgrading to TLS Within HTTP/1.1 ([RFC 2817](https://datatracker.ietf.org/doc/html/rfc2817))
Expand Down
2 changes: 1 addition & 1 deletion httoop/codecs/application/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from defusedxml.ElementTree import ParseError, fromstring, tostring
except ImportError: # pragma: no cover
# TODO: emit a warning
from xml.etree.ElementTree import ParseError, tostring
from xml.etree.ElementTree import ParseError, tostring # noqa: S405

def fromstring(data) -> NoReturn:
raise ParseError('Will not parse without defusedxml!')
Expand Down
4 changes: 2 additions & 2 deletions httoop/messages/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def safe(self) -> bool:
def idempotent(self) -> bool:
return self in self.idempotent_methods

safe_methods = ('GET', 'HEAD', 'SEARCH')
idempotent_methods = ('GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS', 'TRACE', 'SEARCH')
safe_methods = ('GET', 'HEAD', 'SEARCH', 'QUERY')
idempotent_methods = ('GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS', 'TRACE', 'SEARCH', 'QUERY')
METHOD_RE = re.compile(rb'^[A-Z0-9$_.-]{1,20}\Z', re.IGNORECASE)

def __init__(self, method: str | None = None) -> None:
Expand Down
75 changes: 74 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ unsafe-fixes = true
preview = true
select = ["E", "W", "F", "I", "D", "TD", "ALL"]
ignore = [
# Invalid / don't care:
"E501", # line-too-long
"E203", # whitespace-before-punctuation
"COM812", # missing-trailing-comma
Expand All @@ -102,16 +103,24 @@ ignore = [
"D404", # First word of the docstring should not be "This"
"D413", # missing-blank-line-after-last-section
"D104", # Missing docstring in public package
"DOC201", # docstring-missing-returns
"DOC402", # docstring-missing-yields
"DOC501", # docstring-missing-exception
"EM101", # raw-string-in-exception
"ERA001", # commented-out-code
"T201", "T203", # print, p-print
"TD001", # invalid-todo-tag
"TD002", # missing-todo-author
"TD003", # missing-todo-link
"RSE102", # unnecessary-paren-on-raise-exception
"UP031", # printf-string-formatting
"CPY", # copyright
"EM102", # f-string-in-exception
# "I", "S101", "Q000", "ANN", "ERA", "UP004", "ARG001", "ARG002",
"FURB189", # subclass-builtin
"TRY301", # raise-within-try

# too much effort:
"ANN001", # missing-type-function-argument
"ANN201", # missing-return-type-undocumented-public-function
"ANN202", # missing-return-type-private-function
Expand All @@ -120,6 +129,65 @@ ignore = [
"ANN401", # any-type
"ANN204", # missing-return-type-special-method
"ANN206", # missing-return-type-class-method

"ARG001", # unused-function-argument
"ARG003", # unused-class-method-argument
"FIX001", # line-contains-fixme
"FIX002", # line-contains-todo
"PLC2701", # import-private-name
"PLR0904", # too-many-public-methods
"PLR0912", # too-many-branches

# needs decision:
"PLC2801", # unnecessary-dunder-call
"TRY003", # raise-vanilla-args
"TRY300", # try-consider-else

# should be fixed!
"A001", # builtin-variable-shadowing
"A003", # builtin-attribute-shadowing
"B015", # useless-comparison
"B018", # useless-expression
"B904", # raise-without-from-inside-except
"D301", # escape-sequence-in-docstring
"DTZ001", # call-datetime-without-tzinfo
"DTZ004", # call-datetime-utcfromtimestamp
"FBT001", # boolean-type-hint-positional-argument
"FBT002", # boolean-default-value-positional-argument
"FBT003", # boolean-positional-value-in-call
"FURB113", # repeated-append
"N802", # invalid-function-name
"N803", # invalid-argument-name
"N805", # invalid-first-argument-name-for-method
"N806", # non-lowercase-variable-in-function
"N818", # error-suffix-on-exception-name
"PERF203", # try-except-in-loop
"PLC0206", # dict-index-missing-items
"PLC0415", # import-outside-top-level
"PLC1901", # compare-to-empty-string
"PLR1704", # redefined-argument-from-local
"PLR2004", # magic-value-comparison
"PLR6201", # literal-membership
"PLR6301", # no-self-use
"PLW0108", # unnecessary-lambda
"PLW0717", # too-many-statements-in-try-clause
"PLW1641", # eq-without-hash
"PLW2901", # redefined-loop-name
"PT011", # pytest-raises-too-broad
"PT012", # pytest-raises-with-multiple-statements
"PYI041", # redundant-numeric-union
"PYI056", # unsupported-method-call-on-all
"RUF005", # collection-literal-concatenation
"RUF012", # mutable-class-default
"RUF022", # unsorted-dunder-all
"RUF039", # unraw-re-pattern
"RUF067", # non-empty-init-module
"RUF069", # float-equality-comparison
"SIM102", # collapsible-if
"SIM108", # if-else-block-instead-of-if-exp
"SIM115", # open-file-with-context-handler
"RUF100", # unused-noqa
"S101", # assert
]


Expand Down Expand Up @@ -154,7 +222,12 @@ task-tags = ["TODO", "FIXME"]
[tool.ruff.lint.extend-per-file-ignores]
"tests/*" = [
"ANN",
"S101",
"S101", # assert
"S105", # hardcoded-password-string
"S108", # hardcoded-temp-file
"S404", # suspicious-subprocess-import
"S405", # suspicious-xml-etree-import
"S603", # subprocess-without-shell-equals-true
]
"httoop/status/*.py" = [
"N801",
Expand Down
Loading
Loading