No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
5e530ae
... +0 ...
ed5da96
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | + | # pylint: disable=C0115,C0116 |
|
2 | 3 | """ |
|
3 | 4 | @file |
|
4 | 5 | @brief Quelques questions d'ordre général autour du langage Python. |
128 | 129 | Cette fonction dit si les deux objets sont en fait le même objet (True) |
|
129 | 130 | ou non (False) s'ils sont différents (même s'ils contiennent la même information). |
|
130 | 131 | ||
131 | - | @param a n'importe quel objet |
|
132 | - | @param b n'importe quel objet |
|
133 | - | @return ``True`` ou ``False`` |
|
132 | + | :param a: n'importe quel objet |
|
133 | + | :param b: n'importe quel objet |
|
134 | + | :return: ``True`` ou ``False`` |
|
134 | 135 | ||
135 | 136 | .. faqref:: |
|
136 | 137 | :tag: python |
241 | 242 | """ |
|
242 | 243 | returns a StringIO object on a text |
|
243 | 244 | ||
244 | - | @param text any text |
|
245 | - | @return StringIO object |
|
245 | + | :param text: any text |
|
246 | + | :return: StringIO object |
|
246 | 247 | ||
247 | 248 | .. faqref:: |
|
248 | 249 | :tag: python |
359 | 360 | """ |
|
360 | 361 | Cette fonction itère sur les différentes occurences d'une expression régulière. |
|
361 | 362 | ||
362 | - | @param exp expression régulière |
|
363 | - | @param text text à parser |
|
364 | - | @return itérateur |
|
363 | + | :param exp: expression régulière |
|
364 | + | :param text: text à parser |
|
365 | + | :return: itérateur |
|
365 | 366 | ||
366 | 367 | .. faqref:: |
|
367 | 368 | :tag: regex |
538 | 539 | """ |
|
539 | 540 | returns the month name for a give date |
|
540 | 541 | ||
541 | - | @param date datatime |
|
542 | - | @return month name |
|
542 | + | :param date: datatime |
|
543 | + | :return: month name |
|
543 | 544 | ||
544 | 545 | .. faqref:: |
|
545 | 546 | :tag: python |
559 | 560 | """ |
|
560 | 561 | returns the day name for a give date |
|
561 | 562 | ||
562 | - | @param date datatime |
|
563 | - | @return month name |
|
563 | + | :param date: datatime |
|
564 | + | :return: month name |
|
564 | 565 | ||
565 | 566 | .. faqref:: |
|
566 | 567 | :tag: python |
574 | 575 | print(dt.strftime("%A")) |
|
575 | 576 | """ |
|
576 | 577 | return date.strftime("%A") |
|
578 | + | ||
579 | + | ||
580 | + | def class_getitem(): |
|
581 | + | """ |
|
582 | + | This function shows how to enable an expression such as |
|
583 | + | `A[1]` where `A` is a class type and not an instance. |
|
584 | + | This can be done through `__class_getitem__ |
|
585 | + | <https://docs.python.org/3/reference/datamodel.html#object.__class_getitem__>`_. |
|
586 | + | """ |
|
587 | + | ||
588 | + | class A: |
|
589 | + | def __init__(self): |
|
590 | + | pass |
|
591 | + | ||
592 | + | @classmethod |
|
593 | + | def get(cls, index): |
|
594 | + | if index == 1: |
|
595 | + | return A1 |
|
596 | + | if index == 2: |
|
597 | + | return A2 |
|
598 | + | assert False # pragma: no cover |
|
599 | + | ||
600 | + | @classmethod |
|
601 | + | def __class_getitem__(cls, index): |
|
602 | + | return cls.get(index) |
|
603 | + | ||
604 | + | def __getitem__(self, index): |
|
605 | + | return "i[%d]" % index |
|
606 | + | ||
607 | + | class A1(A): |
|
608 | + | def __init__(self): |
|
609 | + | A.__init__(self) |
|
610 | + | ||
611 | + | class A2(A): |
|
612 | + | def __init__(self): |
|
613 | + | A.__init__(self) |
|
614 | + | ||
615 | + | a = A() |
|
616 | + | assert a[5] == "i[5]" |
|
617 | + | assert a.__class__.__name__ == "A" |
|
618 | + | ||
619 | + | a = A.get(1)() |
|
620 | + | assert a.__class__.__name__ == "A1" |
|
621 | + | ||
622 | + | a = A[1]() |
|
623 | + | assert a.__class__.__name__ == "A1" |
|
624 | + | ||
625 | + | a = A[2]() |
|
626 | + | assert a.__class__.__name__ == "A2" |
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | + | # pylint: disable=W4701 |
|
2 | 3 | """ |
|
3 | 4 | @file |
|
4 | 5 | @brief quelques fonctions à propos de la première séance |
219 | 220 | il est conseillé de s'en abstenir ainsi que pour tout type d'objets qui en contient d'autres. |
|
220 | 221 | C'est une habitude qui vous servira pour la plupart des autres langages. |
|
221 | 222 | """ |
|
222 | - | li = [0, 1, 2, 3, 4, 5, 6] |
|
223 | - | for i in li: |
|
223 | + | liste = [0, 1, 2, 3, 4, 5, 6] |
|
224 | + | for i in liste: |
|
224 | 225 | if i == 2: |
|
225 | - | li.remove(3) |
|
226 | + | liste.remove(3) |
|
226 | 227 | ||
227 | - | d = {k: k for k in li} |
|
228 | + | d = {k: k for k in liste} |
|
228 | 229 | rem = [] |
|
229 | 230 | for k in d: |
|
230 | 231 | if k == 4: |
|
231 | 232 | rem.append(k) |
|
232 | 233 | for r in rem: |
|
233 | 234 | del d[r] |
|
234 | 235 | ||
235 | - | return li, d |
|
236 | + | return liste, d |
|
236 | 237 | ||
237 | 238 | ||
238 | 239 | def str2date(s, format="%d/%m/%Y"): |
Files | Coverage |
---|---|
src/teachpyx | 0.08% 99.52% |
Project Totals (8 files) | 99.52% |
ed5da96
5e530ae