33
44import datetime
55import urllib .parse
6- from typing import Optional , Set , TYPE_CHECKING
6+ from typing import Optional , Set , TYPE_CHECKING , Tuple , Union
77
88if TYPE_CHECKING :
99 from tibiapy .enums import (BazaarType , HighscoresBattlEyeType , HighscoresCategory , HighscoresProfession , HouseOrder ,
1212 from tibiapy .models import AuctionFilters
1313
1414
15- def get_tibia_url (section , subtopic = None , * args , anchor = None , test = False , ** kwargs ):
15+ def get_tibia_url (
16+ section : str ,
17+ subtopic : str = None ,
18+ * args : Tuple [str , Union [str , int ]],
19+ anchor : str = None ,
20+ test : bool = False ,
21+ ** kwargs : Union [str , int ],
22+ ) -> str :
1623 """Build a URL to Tibia.com with the given parameters.
1724
1825 Parameters
1926 ----------
2027 section: :class:`str`
21- The desired section (e.g. community, abouttibia, manual, library)
28+ The desired section (e.g., community, abouttibia, manual, library)
2229 subtopic: :class:`str`, optional
23- The desired subtopic (e.g. characters, guilds, houses, etc)
30+ The desired subtopic (e.g., characters, guilds, houses, etc. )
2431 anchor: :class:`str`
2532 A link anchor to add to the link.
2633 args:
2734 A list of key-value pairs to add as query parameters.
2835 This allows passing multiple parameters with the same name.
2936 kwargs:
30- Additional parameters to pass to the url as query parameters (e.g name, world, houseid, etc)
37+ Additional parameters to pass to the url as query parameters (e.g., name, world, houseid, etc. )
3138 test: :class:`bool`
3239 Whether to use the test website or not.
3340
@@ -58,7 +65,7 @@ def get_tibia_url(section, subtopic=None, *args, anchor=None, test=False, **kwar
5865 if value is None :
5966 continue
6067
61- params [key ] = value
68+ params [key ] = str ( value )
6269
6370 url += urllib .parse .urlencode (params )
6471 if args :
@@ -104,7 +111,7 @@ def get_character_url(name: str) -> str:
104111
105112
106113def get_world_guilds_url (world : str ) -> str :
107- """Get the URL to guild list of a specific world.
114+ """Get the URL to the guild list of a specific world.
108115
109116 Parameters
110117 ----------
@@ -146,7 +153,7 @@ def get_guild_wars_url(name: str) -> str:
146153 Returns
147154 -------
148155 :class:`str`
149- The URL to the guild's wars page.
156+ The URL to the guild's wars' page.
150157 """
151158 return get_tibia_url ("community" , "guilds" , page = "guildwars" , action = "view" , GuildName = name )
152159
@@ -260,7 +267,7 @@ def get_forum_section_url_by_name(section_name: str) -> str:
260267 return get_tibia_url ("forum" , section_name )
261268
262269
263- def get_world_boards_url ():
270+ def get_world_boards_url () -> str :
264271 """Get the URL to the World Boards section in Tibia.com.
265272
266273 Returns
@@ -271,7 +278,7 @@ def get_world_boards_url():
271278 return get_tibia_url ("forum" , "worldboards" )
272279
273280
274- def get_trade_boards_url ():
281+ def get_trade_boards_url () -> str :
275282 """Get the URL to the Trade Boards section in Tibia.com.
276283
277284 Returns
@@ -282,7 +289,7 @@ def get_trade_boards_url():
282289 return get_tibia_url ("forum" , "tradeboards" )
283290
284291
285- def get_community_boards_url ():
292+ def get_community_boards_url () -> str :
286293 """Get the URL to the Community Boards section in Tibia.com.
287294
288295 Returns
@@ -293,7 +300,7 @@ def get_community_boards_url():
293300 return get_tibia_url ("forum" , "communityboards" )
294301
295302
296- def get_support_boards_url ():
303+ def get_support_boards_url () -> str :
297304 """Get the URL to the Support Boards section in Tibia.com.
298305
299306 Returns
@@ -360,7 +367,7 @@ def get_forum_thread_url(thread_id: int, page: int = 1) -> str:
360367 return get_tibia_url ("forum" , None , action = "thread" , threadid = thread_id , pagenumber = page )
361368
362369
363- def get_forum_post_url (post_id ) :
370+ def get_forum_post_url (post_id : int ) -> str :
364371 """Get the URL to a specific post.
365372
366373 Parameters
@@ -380,7 +387,7 @@ def get_highscores_url(
380387 world : str = None ,
381388 category : HighscoresCategory = None ,
382389 vocation : HighscoresProfession = None ,
383- page = 1 ,
390+ page : int = 1 ,
384391 battleye_type : HighscoresBattlEyeType = None ,
385392 pvp_types : Set [PvpTypeFilter ] = None ,
386393) -> str :
@@ -485,7 +492,7 @@ def get_houses_section_url(world: str, town: str, house_type: HouseType, status:
485492 return get_tibia_url ("community" , "houses" , ** {k : v for k , v in params .items () if v is not None })
486493
487494
488- def get_auction_url (auction_id : int ):
495+ def get_auction_url (auction_id : int ) -> str :
489496 """Get the URL to the Tibia.com detail page of an auction with a given id.
490497
491498 Parameters
@@ -501,7 +508,7 @@ def get_auction_url(auction_id: int):
501508 return get_tibia_url ("charactertrade" , "currentcharactertrades" , page = "details" , auctionid = auction_id )
502509
503510
504- def get_bazaar_url (type : BazaarType , page : int = 1 , filters : AuctionFilters = None ):
511+ def get_bazaar_url (type : BazaarType , page : int = 1 , filters : AuctionFilters = None ) -> str :
505512 """Get the URL to the list of current auctions in Tibia.com.
506513
507514 Parameters
@@ -522,7 +529,7 @@ def get_bazaar_url(type: BazaarType, page: int = 1, filters: AuctionFilters = No
522529 return get_tibia_url ("charactertrade" , type .subtopic , currentpage = page , ** query_params )
523530
524531
525- def get_cm_post_archive_url (from_date : datetime .date , to_date : datetime .date , page = 1 ) :
532+ def get_cm_post_archive_url (from_date : datetime .date , to_date : datetime .date , page : int = 1 ) -> str :
526533 """Get the URL to the CM Post Archive for the given date range.
527534
528535 Parameters
@@ -629,7 +636,7 @@ def get_boostable_bosses_url() -> str:
629636 return get_tibia_url ("library" , "boostablebosses" )
630637
631638
632- def _to_yes_no (value : Optional [bool ]):
639+ def _to_yes_no (value : Optional [bool ]) -> Optional [ str ] :
633640 if value is None :
634641 return None
635642
@@ -642,7 +649,7 @@ def get_spells_section_url(
642649 spell_type : SpellType = None ,
643650 is_premium : bool = None ,
644651 sort : SpellSorting = None ,
645- ):
652+ ) -> str :
646653 """Get the URL to the spells section with the desired filtering parameters.
647654
648655 Parameters
0 commit comments