]> git.madduck.net Git - etc/vim.git/blob - tests/data/comments.py

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Link to Bugbear's documentation (#577)
[etc/vim.git] / tests / data / comments.py
1 #!/usr/bin/env python3
2 # fmt: on
3 # Some license here.
4 #
5 # Has many lines. Many, many lines.
6 # Many, many, many lines.
7 """Module docstring.
8
9 Possibly also many, many lines.
10 """
11
12 import os.path
13 import sys
14
15 import a
16 from b.c import X  # some noqa comment
17
18 try:
19     import fast
20 except ImportError:
21     import slow as fast
22
23
24 # Some comment before a function.
25
26
27 def function(default=None):
28     """Docstring comes first.
29
30     Possibly many lines.
31     """
32     # FIXME: Some comment about why this function is crap but still in production.
33     import inner_imports
34
35     if inner_imports.are_evil():
36         # Explains why we have this if.
37         # In great detail indeed.
38         x = X()
39         return x.method1()  # type: ignore
40
41     # This return is also commented for some reason.
42     return default
43
44
45 # Explains why we use global state.
46 GLOBAL_STATE = {"a": a(1), "b": a(2), "c": a(3)}
47
48
49 # Another comment!
50 # This time two lines.
51
52
53 class Foo:
54     """Docstring for class Foo.  Example from Sphinx docs."""
55
56     #: Doc comment for class attribute Foo.bar.
57     #: It can have multiple lines.
58     bar = 1
59
60     flox = 1.5  #: Doc comment for Foo.flox. One line only.
61
62     baz = 2
63     """Docstring for class attribute Foo.baz."""
64
65     def __init__(self):
66         #: Doc comment for instance attribute qux.
67         self.qux = 3
68
69         self.spam = 4
70         """Docstring for instance attribute spam."""
71
72
73 #' <h1>This is pweave!</h1>
74
75
76 @fast(really=True)
77 async def wat():
78     async with X.open_async() as x:  # Some more comments
79         result = await x.method1()
80     # Comment after ending a block.
81     if result:
82         print("A OK", file=sys.stdout)
83         # Comment between things.
84         print()
85
86
87 # Some closing comments.
88 # Maybe Vim or Emacs directives for formatting.
89 # Who knows.