-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_rules.py
37 lines (29 loc) · 1.23 KB
/
import_rules.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
----------------------------------------------------------------------------------
[2.2 Import Rules](https://docs.sourcery.ai/Reference/Custom-Rules/gpsg/#22-import-rules)
----------------------------------------------------------------------------------
This example file contains pieces of code that either comply with or violate the
import rules `no-wildcard-imports` and `no-relative-imports`, as well as the
rules for standardized import aliases `use-standard-name-for-aliases-*`.
"""
# no violation
import time
# violations of `no-wildcard-imports`
from time import *
from rich.table import *
# violations of `no-relative-imports`
from . import important_function
from .my_module import important_function
from ..my_module import important_function, unimportant_function
# no violation - this is an absolute member import
from my_company.my_module import important_function
# violation of both `no-wildcard-imports` and `no-relative-imports`
from .something import *
# no violations: import common libraries with their "standard" aliases
import numpy as np
import pandas as pd
import tensorflow as tf
# violations of `use-standard-name-for-aliases-*`: warning: chaos ahead!
import numpy as pd
import pandas as tf
import tensorflow as np