This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from decimal import Decimal | |
from typing import List, NewType, Optional | |
from pydantic import BaseModel, Field | |
PersonId = NewType("PersonId", int) | |
class Person(BaseModel): | |
id: PersonId |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"id": 1, "name": "Anna", "friends": [2, 3, 4], "birthdate": "1992-01-15", "bank_account": 12.3}, | |
{"id": 2, "name": "Bob", "friends": null, "birthdate": "1962-12-31", "bank_account": 0.1}, | |
{"id": 3, "name": "Charlie", "friends": [4], "birthdate": "1992-02-28", "bank_account": 9007199254740993.0}, | |
{"id": 4, "name": "Martin", "friends": [1, 3], "birthdate": "1990-04-28", "bank_account": 9007199254740993} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from pathlib import Path | |
from typing import Any, Mapping | |
import numpy as np | |
def main(filepath: Path): | |
people = get_people(filepath) | |
friends_difference = get_account_difference(people) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This file was initially generated by Windows Terminal 1.2.2381.0 | |
// It should still be usable in newer versions, but newer versions might have additional | |
// settings, help text, or changes that you will not see unless you clear this file | |
// and let us generate a new one for you. | |
// To view the default settings, hold "alt" while clicking on the "Settings" button. | |
// For documentation on these settings, see: https://aka.ms/terminal-documentation | |
{ | |
"$schema": "https://aka.ms/terminal-profiles-schema", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_unary_not_equality(): | |
ret = _results("not a == b") | |
assert ret == {("1:0 SIM201 Used 'not a == b' instead of 'a != b'")} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Core Library | |
import ast | |
from typing import Set | |
# First party | |
from flake8_simplify import Plugin | |
def _results(code: str) -> Set[str]: | |
"""Apply the plugin to the given code.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ast | |
from typing import Any, DefaultDict, Generator, List, Tuple, Type | |
class Visitor(ast.NodeVisitor): | |
def __init__(self) -> None: | |
self.errors: List[Tuple[int, int, str]] = [] | |
def visit_UnaryOp(self, node: ast.UnaryOp) -> None: | |
self.errors += _get_not_equal_calls(node) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
if sys.version_info < (3, 8): # pragma: no cover (<PY38) | |
# Third party | |
import importlib_metadata | |
else: # pragma: no cover (PY38+) | |
# Core Library | |
import importlib.metadata as importlib_metadata |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_meta_numpydoc(filepath, a_number, a_dict): | |
""" | |
Get meta-information of an image. | |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo | |
ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis | |
parturient montes, nascetur ridiculus mus. | |
Parameters | |
---------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Plugin-Name | description | comment | |
---|---|---|---|
danger-flake8 | no description | ||
dh2flake8 | |||
flake8 | |||
flake8-2020 | potential typo squat | ||
flake8-aaa | Arrange-Act-Assert: A style check for unit test structure | ||
flake8-absolute-import | Prevent relative imports | ||
flake8-adjustable-complexity | cyclomatic complexity | ||
flake8-alfred | unclear | ||
flake8-annotations | support mypy | seems not to be necessary if you use mypy |