o
    zi                     @   s   d Z ddlZddlmZ ddlmZmZmZ ddlm	Z	 ej
de	d ejZdd	ed
dfddZ	ddeeef dee dededee d
efddZee_G dd deZded
efddZdS )zWarning-related utilities.    N)Path)OptionalTypeUnion)LightningDeprecationWarningdefault)category modulereturnc                 C   s   t jd| td dS )au  Ignore warnings of the category ``PossibleUserWarning`` from Lightning.

    For more granular control over which warnings to ignore, use :func:`warnings.filterwarnings` directly.

    Args:
        module: Name of the module for which the warnings should be ignored (e.g., ``'pytorch_lightning.strategies'``).
            Default: Disables warnings from all modules.

    ignore)r
   r   N)warningsfilterwarningsPossibleUserWarning)r
    r   W/home/ubuntu/.local/lib/python3.10/site-packages/lightning_fabric/utilities/warnings.pydisable_possible_user_warnings   s   
r   messager   filenamelinenolinec                 C   s2   t t|r| d| d|  dS t| ||||S )zhCustom formatting that avoids an extra line in case warnings are emitted from the `rank_zero`-functions.:z: 
)_is_path_in_lightningr   _default_format_warning)r   r   r   r   r   r   r   r   _custom_format_warning(   s   r   c                   @   s   e Zd ZdZdS )r   z'Warnings that could be false positives.N)__name__
__module____qualname____doc__r   r   r   r   r   5   s    r   pathc                 C   s   dt |  v S )zJNaive check whether the path looks like a path from the lightning package.	lightning)strabsolute)r    r   r   r   r   9   s   r   )r	   )N)r   r   pathlibr   typingr   r   r   $lightning_fabric.utilities.rank_zeror   simplefilterformatwarningr   r"   r   Warningintr   UserWarningr   boolr   r   r   r   r   <module>   s2   


