File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
tests/functional/r/regression Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ Release date: TBA
2222
2323 Closes #4886
2424
25+ * Fix a crash in the checker raising ``shallow-copy-environ`` when failing to infer
26+ on ``copy.copy``
27+
28+ Closes #4896
29+
30+
2531
2632What's New in Pylint 2.10.1?
2733============================
Original file line number Diff line number Diff line change @@ -483,9 +483,13 @@ def _check_for_check_kw_in_run(self, node):
483483 if "check" not in kwargs :
484484 self .add_message ("subprocess-run-check" , node = node )
485485
486- def _check_shallow_copy_environ (self , node ) :
486+ def _check_shallow_copy_environ (self , node : nodes . Call ) -> None :
487487 arg = utils .get_argument_from_call (node , position = 0 )
488- for inferred in arg .inferred ():
488+ try :
489+ inferred_args = arg .inferred ()
490+ except astroid .InferenceError :
491+ return
492+ for inferred in inferred_args :
489493 if inferred .qname () == OS_ENVIRON :
490494 self .add_message ("shallow-copy-environ" , node = node )
491495 break
@@ -505,7 +509,7 @@ def _check_shallow_copy_environ(self, node):
505509 "unspecified-encoding" ,
506510 "forgotten-debug-statement" ,
507511 )
508- def visit_call (self , node ) :
512+ def visit_call (self , node : nodes . Call ) -> None :
509513 """Visit a Call node."""
510514 self .check_deprecated_class_in_call (node )
511515 for inferred in utils .infer_all (node .func ):
Original file line number Diff line number Diff line change 1+ # pylint: disable=missing-module-docstring
2+ # pylint: disable=too-few-public-methods
3+ import copy
4+
5+ class MyData :
6+ '''
7+ class docstring
8+ '''
9+ def __init__ (self ):
10+ self .data = {}
11+
12+ def process (self ):
13+ '''
14+ another method is responsible for putting "static_key"
15+ '''
16+ copy .copy (self .data ['static_key' ])
You can’t perform that action at this time.
0 commit comments