@@ -81,7 +81,7 @@ class PathError(Error):
8181 pass
8282
8383
84- def replacement_list (string , sep = "#" ):
84+ def get_replacement_list (string , sep = "#" ):
8585 if isinstance (string , list ):
8686 return string
8787 return string .split (sep ) if string else []
@@ -95,7 +95,7 @@ class Match:
9595 ("fromy" , int ), ("fromx" , int ), ("toy" , int ), ("tox" , int ),
9696 ("frompos" , int ), ("topos" , int ),
9797 ("ruleId" , str ), ("subId" , str ), ("msg" , str ),
98- ("replacements" , replacement_list ),
98+ ("replacements" , get_replacement_list ),
9999 ("context" , str ), ("contextoffset" , int ), ("errorlength" , int ),
100100 ("url" , str ),
101101 ])
@@ -166,12 +166,16 @@ def __getattr__(self, name):
166166
167167 @property
168168 def _frompos (self ):
169+ """Position of the start of the error
170+ """
169171 if self ._frompos_cache is None :
170172 self ._frompos_cache = self ._get_pos (self .fromy , self .fromx )
171173 return self ._frompos_cache
172174
173175 @property
174176 def _topos (self ):
177+ """Position of the end of the error
178+ """
175179 if self ._topos_cache is None :
176180 self ._topos_cache = self ._get_pos (self .toy , self .tox )
177181 return self ._topos_cache
@@ -291,7 +295,9 @@ def disable_spellchecking(self):
291295 self .disabled .update (self ._spell_checking_rules )
292296
293297 @classmethod
294- def _get_languages (cls ):
298+ def _get_languages (cls ) -> set :
299+ """Get supported languages (by querying the server).
300+ """
295301 if not cls ._server_is_alive ():
296302 cls ._start_server_on_free_port ()
297303 url = urllib .parse .urljoin (cls ._url , "Languages" )
@@ -453,7 +459,7 @@ def correct(text: str, matches: [Match]) -> str:
453459
454460
455461def get_version ():
456- """Get LanguageTool version as a string .
462+ """Get LanguageTool version.
457463 """
458464 try :
459465 return cache ["version" ]
@@ -481,8 +487,8 @@ def get_version():
481487 return version
482488
483489
484- def get_languages ():
485- """Get available languages as a set .
490+ def get_languages () -> set :
491+ """Get supported languages.
486492 """
487493 try :
488494 languages = cache ["languages" ]
@@ -495,7 +501,9 @@ def get_languages():
495501 return languages
496502
497503
498- def get_languages_from_dir ():
504+ def get_languages_from_dir () -> set :
505+ """Get supported languages (by scanning the LanguageTool directory).
506+ """
499507 rules_path = os .path .join (get_directory (), "rules" )
500508 languages = {fn for fn in os .listdir (rules_path )
501509 if os .path .isdir (os .path .join (rules_path , fn )) and
0 commit comments