-
Notifications
You must be signed in to change notification settings - Fork 883
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
186b276
commit b5775b8
Showing
3 changed files
with
353 additions
and
282 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,120 @@ | ||
# Violation cases: RUF026 | ||
|
||
from collections import defaultdict | ||
|
||
# Violation cases: RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict(default_factory=None) # RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict(default_factory=int) # RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict(default_factory=float) # RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict(default_factory=dict) # RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict(default_factory=list) # RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict(default_factory=tuple) # RUF026 | ||
|
||
|
||
def func(): | ||
def foo(): | ||
pass | ||
|
||
defaultdict(default_factory=foo) # RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict(default_factory=lambda: 1) # RUF026 | ||
|
||
|
||
def func(): | ||
from collections import deque | ||
|
||
defaultdict(default_factory=deque) # RUF026 | ||
|
||
|
||
def func(): | ||
class MyCallable: | ||
def __call__(self): | ||
pass | ||
|
||
defaultdict(default_factory=MyCallable()) # RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict(default_factory=tuple, member=1) # RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict(member=1, default_factory=tuple) # RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict(member=1, default_factory=tuple,) # RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict( | ||
member=1, | ||
default_factory=tuple, | ||
) # RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict( | ||
default_factory=tuple, | ||
member=1, | ||
) # RUF026 | ||
|
||
|
||
# Non-violation cases: RUF026 | ||
|
||
|
||
def func(): | ||
defaultdict(default_factory=1) # OK | ||
|
||
|
||
def func(): | ||
defaultdict(default_factory="wdefwef") # OK | ||
|
||
|
||
def func(): | ||
defaultdict(default_factory=[1,2,3]) # OK | ||
defaultdict(default_factory=[1, 2, 3]) # OK | ||
|
||
|
||
def func(): | ||
defaultdict() # OK | ||
|
||
|
||
def func(): | ||
defaultdict(int) # OK | ||
|
||
|
||
def func(): | ||
defaultdict(list) # OK | ||
|
||
|
||
def func(): | ||
defaultdict(dict) # OK | ||
|
||
|
||
def func(): | ||
defaultdict(dict, defaultdict=list) # OK | ||
|
||
|
||
def func(): | ||
def constant_factory(value): | ||
return lambda: value | ||
defaultdict(constant_factory('<missing>')) | ||
|
||
defaultdict(constant_factory("<missing>")) |
Oops, something went wrong.