
    e                    z    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZmZ erddlmZ  G d d	e      Zdd
Zy)zmChecker for features used that are not supported by all python versions
indicated by the py-version setting.
    )annotations)TYPE_CHECKING)nodes)BaseChecker)only_required_for_messages
safe_inferuninferable_final_decorators)PyLinterc                  j    e Zd ZdZdZdddZddZ ed      dd       Z ed	      dd
       Z	ddZ
y)UnsupportedVersionCheckerzpChecker for features that are not supported by all python versions
    indicated by the py-version setting.
    unsupported_version)zNF-strings are not supported by all versions included in the py-version setting%using-f-string-in-unsupported-versionz]Used when the py-version set by the user is lower than 3.6 and pylint encounters an f-string.)zPtyping.final is not supported by all versions included in the py-version setting,using-final-decorator-in-unsupported-versionznUsed when the py-version set by the user is lower than 3.8 and pylint encounters a ``typing.final`` decorator.)W2601W2602c                l    | j                   j                  j                  }|dk\  | _        |dk\  | _        y)z*Initialize visit variables and statistics.)      )r      N)linterconfig
py_version
_py36_plus
_py38_plus)selfr   s     E/usr/lib/python3/dist-packages/pylint/checkers/unsupported_version.pyopenzUnsupportedVersionChecker.open/   s/    [[''22
$.$.    r   c                D    | j                   s| j                  d|       yy)zCheck f-strings.r   nodeN)r   add_messager   r!   s     r   visit_joinedstrz)UnsupportedVersionChecker.visit_joinedstr5   s$     D4P r   r   c                &    | j                  |       y)zCheck decorators.N)_check_typing_finalr#   s     r   visit_decoratorsz*UnsupportedVersionChecker.visit_decorators;   s     	  &r   c                    | j                   ryg }|j                         D ]5  }t        |      }|s|j                         dk(  s%|j	                  |       7 |xs t        |      D ]  }| j                  d|        y)znAdd a message when the `typing.final` decorator is used and the
        py-version is lower than 3.8.
        Nztyping.finalr   r    )r   get_childrenr   qnameappendr	   r"   )r   r!   
decorators	decoratorinferreds        r   r&   z-UnsupportedVersionChecker._check_typing_final@   s     ??
**, 	-I!),HHNN,>!!),	-
 $I'CD'I 	I>Y  	r   N)returnNone)r!   znodes.JoinedStrr/   r0   )r!   znodes.Decoratorsr/   r0   )__name__
__module____qualname____doc__namemsgsr   r   r$   r'   r&    r   r   r   r      sa     !D

D/   GHQ IQ
   NO' P'r   r   c                8    | j                  t        |              y )N)register_checkerr   )r   s    r   registerr:   S   s    
5f=>r   N)r   r
   r/   r0   )r4   
__future__r   typingr   astroidr   pylint.checkersr   pylint.checkers.utilsr   r   r	   pylint.lintr
   r   r:   r7   r   r   <module>rA      s<   
 #    '  $6 6r?r   