Skip to content
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

[doc] Use the new multiple file template for I <= message-symbol < M #9028

Merged
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ repos:
tests(/\w*)*/functional/m/missing/missing_final_newline.py|
tests/functional/t/trailing_newlines.py|
doc/data/messages/t/trailing-newlines/bad.py|
doc/data/messages/m/missing-final-newline/bad.py|
doc/data/messages/m/missing-final-newline/bad/lf.py|
doc/data/messages/m/missing-final-newline/bad/crlf.py
)$
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.288"
Expand Down Expand Up @@ -59,7 +60,8 @@ repos:
doc/data/messages/i/inconsistent-quotes/bad.py|
doc/data/messages/i/invalid-format-index/bad.py|
doc/data/messages/l/line-too-long/bad.py|
doc/data/messages/m/missing-final-newline/bad.py|
doc/data/messages/m/missing-final-newline/bad/crlf.py|
doc/data/messages/m/missing-final-newline/bad/lf.py|
doc/data/messages/m/multiple-statements/bad.py|
doc/data/messages/r/redundant-u-string-prefix/bad.py|
doc/data/messages/s/superfluous-parens/bad.py|
Expand Down
1 change: 1 addition & 0 deletions doc/data/messages/i/implicit-str-concat/bad/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = ["a" "b"] # [implicit-str-concat]
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
x = ["a" "b"] # [implicit-str-concat]

with open("hello.txt" "r") as f: # [implicit-str-concat]
print(f.read())
1 change: 1 addition & 0 deletions doc/data/messages/i/implicit-str-concat/good/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = ["a", "b"]
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
x = ["a", "b"]

with open("hello.txt", "r") as f:
print(f.read())
2 changes: 1 addition & 1 deletion doc/data/messages/i/inconsistent-mro/good.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ class B(A):
pass


class C(B): # or B, A or A but not A, B
class C(B): # or 'B, A' or 'A' but not 'A, B'
pass
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-bool-returned/bad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class BadBool:
class CustomBool:
"""__bool__ returns an int"""

def __bool__(self): # [invalid-bool-returned]
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-bool-returned/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class GoodBool:
class CustomBool:
"""__bool__ returns `bool`"""

def __bool__(self):
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-bytes-returned/bad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class BadBytes:
class CustomBytes:
"""__bytes__ returns <type 'str'>"""

def __bytes__(self): # [invalid-bytes-returned]
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-bytes-returned/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class GoodBytes:
class CustomBytes:
"""__bytes__ returns <type 'bytes'>"""

def __bytes__(self):
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-format-returned/bad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class BadFormat:
class CustomFormat:
"""__format__ returns <type 'int'>"""

def __format__(self, format_spec): # [invalid-format-returned]
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-format-returned/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class GoodFormat:
class CustomFormat:
"""__format__ returns <type 'str'>"""

def __format__(self, format_spec):
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-getnewargs-ex-returned/bad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class BadGetNewArgsEx:
class CustomGetNewArgsEx:
"""__getnewargs_ex__ returns tuple with incorrect arg length"""

def __getnewargs_ex__(self): # [invalid-getnewargs-ex-returned]
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-getnewargs-ex-returned/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class GoodGetNewArgsEx:
class CustomGetNewArgsEx:
"""__getnewargs_ex__ returns <type 'tuple'>"""

def __getnewargs_ex__(self):
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-getnewargs-returned/bad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class BadGetNewArgs:
class CustomGetNewArgs:
"""__getnewargs__ returns an integer"""

def __getnewargs__(self): # [invalid-getnewargs-returned]
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-getnewargs-returned/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class GoodGetNewArgs:
class CustomGetNewArgs:
"""__getnewargs__ returns <type 'tuple'>"""

def __getnewargs__(self):
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-hash-returned/bad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class BadHash:
class CustomHash:
"""__hash__ returns dict"""

def __hash__(self): # [invalid-hash-returned]
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-hash-returned/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class GoodHash:
class CustomHash:
"""__hash__ returns `int`"""

def __hash__(self):
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-index-returned/bad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class BadIndex:
class CustomIndex:
"""__index__ returns a dict"""

def __index__(self): # [invalid-index-returned]
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-index-returned/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class GoodIndex:
class CustomIndex:
"""__index__ returns <type 'int'>"""

def __index__(self):
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-length-hint-returned/bad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class BadLengthHint:
class CustomLengthHint:
"""__length_hint__ returns non-int"""

def __length_hint__(self): # [invalid-length-hint-returned]
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-length-hint-returned/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class GoodLengthHint:
class CustomLengthHint:
"""__length_hint__ returns <type 'int'>"""

def __length_hint__(self):
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-repr-returned/bad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Repr:
class CustomRepr:
"""__repr__ returns <type 'int'>"""

def __repr__(self): # [invalid-repr-returned]
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-repr-returned/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Repr:
class CustomRepr:
"""__repr__ returns <type 'str'>"""

def __repr__(self):
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-str-returned/bad.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Str:
class CustomStr:
"""__str__ returns int"""

def __str__(self): # [invalid-str-returned]
Expand Down
2 changes: 1 addition & 1 deletion doc/data/messages/i/invalid-str-returned/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Str:
class CustomStr:
"""__str__ returns <type 'str'>"""

def __str__(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ def print_name(name="Sarah", /, **kwds):


print_name(name="Jacob") # [kwarg-superseded-by-positional-arg]
# Will print "Sarah"
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ def print_name(name="Sarah", /, **kwds):


print_name("Jacob")
# Will print "Jacob"
3 changes: 2 additions & 1 deletion doc/data/messages/l/logging-format-truncated/bad.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import sys

logging.warning("Here is a variable: %", my_var) # [logging-format-truncated]
logging.warning("Python version: %", sys.version) # [logging-format-truncated]
3 changes: 2 additions & 1 deletion doc/data/messages/l/logging-format-truncated/good.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import sys

logging.warning("Here is a variable: %s", my_var)
logging.warning("Python version: %s", sys.version)
10 changes: 0 additions & 10 deletions doc/data/messages/m/missing-final-newline/bad.py

This file was deleted.

3 changes: 3 additions & 0 deletions doc/data/messages/m/missing-final-newline/bad/crlf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
print("Hello") # CRLF (\r\n)
print("world") # End-of-file (EOF)
# [missing-final-newline]
3 changes: 3 additions & 0 deletions doc/data/messages/m/missing-final-newline/bad/lf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
print("Hello") # LF (\n)
print("world") # End-of-file (EOF)
# [missing-final-newline]
9 changes: 0 additions & 9 deletions doc/data/messages/m/missing-final-newline/good.py

This file was deleted.

3 changes: 3 additions & 0 deletions doc/data/messages/m/missing-final-newline/good/crlf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
print("Hello") # CRLF (\r\n)
print("world") # CRLF (\r\n)
# End-of-file (EOF)
3 changes: 3 additions & 0 deletions doc/data/messages/m/missing-final-newline/good/lf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
print("Hello") # LF (\n)
print("world") # LF (\n)
# End-of-file (EOF)
2 changes: 1 addition & 1 deletion doc/data/messages/m/missing-module-docstring/good.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Module providingFunction printing python version."""
"""Module providing a function printing python version."""
import sys


Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
print("x=%d, y=%d" % (0, 1))
print("x=%(x)d, y=%(y)d" % {"x": 0, "y": 1})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("x=%d, y=%d" % (0, 1))
3 changes: 2 additions & 1 deletion doc/test_messages_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ def assert_message_bad(self, bad_files: list[Path], messages: list[Message]) ->
missing_files = set(bad_files) - raised_files
for missing_file in missing_files:
msg += f"- Missing warning in {missing_file}\n"
msg += f"'{messages[0].symbol}' might need to be added in 'known_multiple_file_messages'.\n\n"
if messages:
msg += f"'{messages[0].symbol}' might need to be added in 'known_multiple_file_messages'.\n\n"
return msg


Expand Down