bg@dZddlmZddlZddlZddlZddlmZddlmZm Z ddl m Z ddl m Z ddlmZejd krdd lmZndd lmZerdd lmZ ddlZdd lmZmZmZmZmZmZd ZnX#e$rPdZdZGddZGddZGddZGddZGddZ d?d@d ZYnwxYwdAd"ZdBd%Z dCd)Z!eZ"Gd*d+eZ#Gd,d-eZ$Gd.d/eZ%Gd0d1e%Z&Gd2d3e%Z'Gd4d5eZ(ej)d6Z*dDd8Z+Gd9d:e Z,dEd>Z-dS)Fz7Checker for spelling errors in comments and docstrings.) annotationsN)Pattern) TYPE_CHECKINGAny)nodes)BaseTokenChecker)only_required_for_messages))Literal)PyLinter)Chunker EmailFilterFilter URLFilterWikiWordFilter get_tokenizerTFceZdZdS)rN__name__ __module__ __qualname__i/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/pylint/checkers/spelling.pyrr, rrceZdZdS)rNrrrrrr/rrrceZdZdS)rNrrrrrr2rrrceZdZddZdS)rwordstrreturnboolctN)NotImplementedErrorselfr s r_skipz Filter._skip6s% %rNr r!r"r#)rrrr)rrrrr5s( & & & & & &rrceZdZdS)rNrrrrrr9s rrtag str | Nonechunkerslist[Chunker] | Nonefilterslist[Filter] | Noner"ctSr%)r)r,r.r0s rrr<s xxr&list[tuple[Any, enchant.ProviderDesc]]c^tr%tjngSr%)PYENCHANT_AVAILABLEenchantBroker list_dictsrrr_get_enchant_dictsr9Ds&,? G7>   & & ( ( (RGrinner_enchant_dicts list[str]c"dgd|DzS)Ncg|] }|d S)rr.0ds r z-_get_enchant_dict_choices..Ls555A1Q4555rr)r:s r_get_enchant_dict_choicesrCIs! 455!4555 55rpyenchant_availabler#r!cx|r%d|D}dd|}nd}|s|dz }|dz }d|dS) Nc@g|]}|dd|djdS)rz ())namer?s rrBz*_get_enchant_dict_help..Ts3LLL1!A$..!A$)...LLLrzAvailable dictionaries: z, z0No available dictionaries : You need to install zboth the python package and z*the system dependency for enchant to work.zSpelling dictionary name. .)join)r:rD dict_as_str enchant_helps r_get_enchant_dict_helprNOspELL8KLLL J$))K2H2HJJ I " ; : :LDD 7 7 7 77rceZdZdZddZdS) WordsWithDigitsFilterzSkips words with digits.r r!r"r#c4td|DS)Nc3>K|]}|VdSr%)isdigit)r@chars r z.WordsWithDigitsFilter._skip..es*33d4<<>>333333r)anyr's rr)zWordsWithDigitsFilter._skipds33d333333rNr*rrr__doc__r)rrrrPrPas.""444444rrPceZdZdZddZdS) WordsWithUnderscoreszSSkips words with underscores. They are probably function parameter names. r r!r"r#c d|vS)N_rr's rr)zWordsWithUnderscores._skipns d{rNr*rWrrrrZrZhs2 rrZc&eZdZUdZded<d dZd S) RegExFilterzParent class for filters using regular expressions. This filter skips any words the match the expression assigned to the class attribute ``_pattern``. z Pattern[str]_patternr r!r"r#cPt|j|Sr%)r#r_matchr's rr)zRegExFilter._skip{s DM''--...rNr*)rrrrX__annotations__r)rrrr^r^rsB //////rr^c2eZdZdZejdZdS)CamelCasedWordzFilter skipping over camelCasedWords. This filter skips any words matching the following regular expression: ^([a-z]\w+[A-Z]+\w+) That is, any words that are camelCasedWords. z^([a-z]+(\d|[A-Z])(?:\w+)?)NrrrrXrecompiler_rrrrdrds,rz899HHHrrdc2eZdZdZejdZdS)SphinxDirectiveszFilter skipping over Sphinx Directives. This filter skips any words matching the following regular expression: ^(:([a-z]+)){1,2}:`([^`]+)(`)? That is, for example, :class:`BaseQuery` z^(:([a-z]+)){1,2}:`([^`]+)(`)?Nrerrrriris,rz;<.replace_code_but_leave_surrounding_characterss%q!!IOOA$6$666r)rrr"r!)CODE_FLANKED_IN_BACKTICK_REGEXsub)r}rs r _strip_code_flanked_in_backticksrs57777 * - -5t  rc PeZdZdZdZddddZddd d eeeee d fd dd dddfddddddfddddddfddddddfdd d dd!dffZ d8d$Z d9d)Z d:d,Z ed-d;d0Zed-dd6Zd7S)?SpellingCheckerz*Check spelling in comments and docstrings.spelling)zEWrong spelling of a word '%s' in a comment: %s %s Did you mean: '%s'?wrong-spelling-in-commentz5Used when a word in comment is not spelled correctly.)zGWrong spelling of a word '%s' in a docstring: %s %s Did you mean: '%s'?wrong-spelling-in-docstringz7Used when a word in docstring is not spelled correctly.)z$Invalid characters %r in a docstringinvalid-characters-in-docstringz;Used when a word in docstring cannot be checked by enchant.)C0401C0402C0403z spelling-dictr=choicez )defaulttypemetavarchoiceshelpzspelling-ignore-wordsstringzz9List of comma separated words that should not be checked.)rrrrzspelling-private-dict-filepathzzIA path to a file that contains the private dictionary; one word per line.zspelling-store-unknown-wordsnynzzTells whether to store unknown words to the private dictionary (see the --spelling-private-dict-file option) instead of raising a message.zmax-spelling-suggestionsintNz:Limits count of emitted suggestions for spelling mistakes.z"spelling-ignore-comment-directivesz2fmt: on,fmt: off,noqa:,noqa,nosec,isort:skip,mypy:zList of comma separated words that should be considered directives if they appear at the beginning of a comment and should not be checked.r"Nonec d|_tsdS|jjj}|sdSd|jjjdD|_|jddgd|jjj dD|_ |jjj r*tj ||jjj |_ntj||_|jjjrt!|_t%|t&gt(t*t,t.t0t2t4g|_d|_dS) NFc6g|]}|Srstripr@ws rrBz(SpellingChecker.open..2s-   AGGII   r,parampylintc6g|]}|Srrrs rrBz(SpellingChecker.open..9s0. . .  GGII. . . r)r.r0T) initializedr5linterconfig spelling_dictspelling_ignore_wordsrs ignore_listextend"spelling_ignore_comment_directivesignore_comment_directive_listspelling_private_dict_filer6 DictWithPWLDictspelling_store_unknown_wordsset unknown_wordsrrkrrrrPrZrdri tokenizer)r( dict_names ropenzSpellingChecker.open*sn "  FK&4   F  #{1GMMcRR    ( 3444. . ['JPPQTUU. . . * ;  8 9!(!44;-H""D  ")i!8!8D  ;  : 1+.55D & )*%$      rmsgidr!r}line_numc~|} tjd|jdd}n#ttf$rd}YnwxYw|drad|vr]|dd}|jD]6}|d|zr|t|dzd}n7d}nd}t|}| |D]7\}} | |z } | } ||j vs | |j vr2|d r't|d kr|d d}| d d} |j | r|j |rn3#tjj$r|d ||f YwxYw|jjjrv| |jvrkt/|jjjd d5} | | ddddn #1swxYwY|j| `|j |} | |jjjd=|| d} tjd|d| }|r|jd d}n| |}|| z }|r|dz }d|zdt|zz}d| }|||d|df}|||| 9dS)Nz^\s+rrG# docstringr{TF)zu'zu"zr'zr"r)r}argsazutf-8)encoding z(\W|^)(z)(\W|$)^z' or '')rfsearchregs IndexErrorAttributeErrorr startswithrlenrrcasefoldrrcheckr6errorsError add_messagerrrrrrwriteaddsuggestmax_spelling_suggestionsindexrK)r(rr}r original_line initial_spaceiter_directivestarts_with_commentr word_start_atlower_cased_wordf suggestions line_segmentracol indicatorall_suggestionrs r_check_spellingzSpellingChecker._check_spellingXs  Igt449!>$**,,#?#?9 B9 B D- ] *M#}} t'''+;t?O+O+O788 8SYY]]ABBx#3ABB#7  %++,<== %++D11>'     5HD7!  {!> B#4+=== *E!(9#3 7 7 7888 999999999999999 &**+;<<<#088>>  2 K M MN#MNN3  ":T":":":LII3*Q-*CC&,,T22C}$&1HC 3Y3T?; !){!;!;mY8MN8M8M8MN  XD AAAAs9 B9 Bs9&+AA3F*F**-GGH==I I tokenslist[tokenize.TokenInfo]c|jsdS|D]z\}}\}}}}|tjkr_|dkr|dr7|drM|drc|d||{dS)NrGz#!/z # pylint:z# type: r)rtokenizeCOMMENTrr)r(rtok_typetoken start_rowr\s rprocess_tokenszSpellingChecker.process_tokenss  F6< T T 1He^iQ8+++>>e&6&6u&=&=>##K00##J//$$%@%SSS T Trrnode nodes.Modulec0||dSr%_check_docstringr(rs r visit_modulezSpellingChecker.visit_module d#####rnodes.ClassDefc0||dSr%rrs rvisit_classdefzSpellingChecker.visit_classdefrr*nodes.FunctionDef | nodes.AsyncFunctionDefc0||dSr%rrs rvisit_functiondefz!SpellingChecker.visit_functiondefs d#####rJnodes.FunctionDef | nodes.AsyncFunctionDef | nodes.ClassDef | nodes.Modulec|jsdS|jsdS|jdz}t|jjD]\}}|d|||z dS)z*Check if the node has any spelling errors.NrGr)rdoc_nodelineno enumeratevalue splitlinesr)r(r start_lineidxr}s rrz SpellingChecker._check_docstrings  F}  F[1_ "4=#6#A#A#C#CDD X XIC  !>jSVFV W W W W X XrN)r"r)rr!r}r!rrr"r)rrr"r)rrr"r)rrr"r)rrr"r)rrr"r)rrrrXrImsgsrC enchant_dictsrNr5optionsrrrr rrrvisit_asyncfunctiondefrrrrrrs44 D     D*  (44]CC..}>QRR     $ 4S     )+1     +%%     'T     1O 4-    g>G@+ + + + \OBOBOBOBbTTTT&  =>>$$$?>$  =>>$$$?>$  =>>$$$?>$ /XXXXXXrrrr rcJ|t|dSr%)register_checkerr)rs rregisterr s$ OF3344444r)NNN)r,r-r.r/r0r1r"r)r"r3)r:r3r"r;)r:r3rDr#r"r!)r}r!r"r!)rr r"r).rX __future__rrfsysrrtypingrrastroidrpylint.checkersrpylint.checkers.utilsr version_infor typing_extensions pylint.lintr r6enchant.tokenizerrrrrrr5 ImportErrorr9rCrNrrPrZr^rdrirkrgrrrr rrrrs> >="""""" %%%%%%%%,,,,,,<<<<<<v))))))%$$$$$$%NNNG                        &&&&&&&&        )-'+)8HHHH 6666 8 8 8 8#"$$ 44444F4446 / / / / /& / / /:::::[::: = = = = ={ = = =((((('(((V",,P!Q!Q    HXHXHXHXHX&HXHXHXV555555sA--ACC