Sourcery Starbot ⭐ refactored ryneandal/pokeapi#1
Conversation
SourceryAI
left a comment
There was a problem hiding this comment.
Due to GitHub API limits, only the first 60 comments can be shown.
| from multiprocessing import cpu_count | ||
|
|
||
| bind = "0.0.0.0:{}".format(os.environ.get("SERVER_PORT", "80")) | ||
| bind = f'0.0.0.0:{os.environ.get("SERVER_PORT", "80")}' |
There was a problem hiding this comment.
Lines 4-4 refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
|
|
||
| MEDIA_DIR = "/media/sprites/{0}" | ||
| IMAGE_DIR = os.getcwd() + "/data/v2/sprites/sprites/" | ||
| IMAGE_DIR = f"{os.getcwd()}/data/v2/sprites/sprites/" |
There was a problem hiding this comment.
Lines 34-34 refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| with context: | ||
| for value in iterable: | ||
| yield value | ||
| yield from iterable |
There was a problem hiding this comment.
Function with_iter refactored with the following changes:
- Replace yield inside for loop with yield from (
yield-from)
| print("building " + table_name) | ||
| print(f"building {table_name}") |
There was a problem hiding this comment.
Function clear_table refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| if len(sub) >= 2: | ||
| sub = sub[1] | ||
| else: | ||
| sub = sub[0] | ||
| sub = sub[1] if len(sub) >= 2 else sub[0] |
There was a problem hiding this comment.
Function scrub_str refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
| past_obj = {} | ||
| past_obj = {"generation": poke_past_type["generation"]} | ||
|
|
||
| # create past types object for this generation | ||
| past_obj["generation"] = poke_past_type["generation"] |
There was a problem hiding this comment.
Function PokemonDetailSerializer.get_past_pokemon_types refactored with the following changes:
- Merge dictionary assignment with declaration (
merge-dict-assign)
This removes the following comments ( why? ):
# create past types object for this generation
| groups = [] | ||
| for group in data: | ||
| groups.append(group["egg_group"]) | ||
|
|
||
| return groups | ||
| return [group["egg_group"] for group in data] |
There was a problem hiding this comment.
Function PokemonSpeciesDetailSerializer.get_pokemon_egg_groups refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Convert for loop into list comprehension (
list-comprehension)
| # serialize chain recursively from tree | ||
| chain = self.build_chain_link_entry(evolution_tree, summary_data) | ||
|
|
||
| return chain | ||
| return self.build_chain_link_entry(evolution_tree, summary_data) |
There was a problem hiding this comment.
Function EvolutionChainDetailSerializer.build_chain refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
This removes the following comments ( why? ):
# serialize chain recursively from tree
| while len(search_stack) > 0: | ||
| while search_stack: |
There was a problem hiding this comment.
Function EvolutionChainDetailSerializer.build_evolution_tree refactored with the following changes:
- Simplify sequence length comparison (
simplify-len-comparison)
| results = [] | ||
|
|
||
| for dex_group in dex_groups: | ||
| results.append(dex_group["version_group"]) | ||
|
|
||
| return results | ||
| return [dex_group["version_group"] for dex_group in dex_groups] |
There was a problem hiding this comment.
Function PokedexDetailSerializer.get_pokedex_version_groups refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Convert for loop into list comprehension (
list-comprehension)
| regions = [] | ||
|
|
||
| for region in data: | ||
| regions.append(region["region"]) | ||
|
|
||
| return regions | ||
| return [region["region"] for region in data] |
There was a problem hiding this comment.
Function VersionGroupDetailSerializer.get_version_group_regions refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Convert for loop into list comprehension (
list-comprehension)
| methods = [] | ||
|
|
||
| for method in learn_method_data: | ||
| methods.append(method["move_learn_method"]) | ||
|
|
||
| return methods | ||
| return [method["move_learn_method"] for method in learn_method_data] |
There was a problem hiding this comment.
Function VersionGroupDetailSerializer.get_learn_methods refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Convert for loop into list comprehension (
list-comprehension)
| results = [] | ||
|
|
||
| for dex_group in dex_groups: | ||
| results.append(dex_group["pokedex"]) | ||
|
|
||
| return results | ||
| return [dex_group["pokedex"] for dex_group in dex_groups] |
There was a problem hiding this comment.
Function VersionGroupDetailSerializer.get_version_groups_pokedexes refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Convert for loop into list comprehension (
list-comprehension)
| def setup_language_name_data(cls, language, name="lang nm"): | ||
|
|
||
| local_language = cls.setup_language_data(name="lang for " + name) | ||
| local_language = cls.setup_language_data(name=f"lang for {name}") |
There was a problem hiding this comment.
Function APIData.setup_language_name_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| def setup_region_name_data(cls, region, name="reg nm"): | ||
|
|
||
| language = cls.setup_language_data(name="lang for " + name) | ||
| language = cls.setup_language_data(name=f"lang for {name}") |
There was a problem hiding this comment.
Function APIData.setup_region_name_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| ): | ||
|
|
||
| language = cls.setup_language_data(name="lang for " + description) | ||
| language = cls.setup_language_data(name=f"lang for {description}") |
There was a problem hiding this comment.
Function APIData.setup_item_attribute_description_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| ): | ||
|
|
||
| language = cls.setup_language_data(name="lang for " + effect) | ||
| language = cls.setup_language_data(name=f"lang for {effect}") |
There was a problem hiding this comment.
Function APIData.setup_item_fling_effect_effect_text_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| def setup_item_pocket_name_data(cls, item_pocket, name="itm pkt nm"): | ||
|
|
||
| language = cls.setup_language_data(name="lang for " + name) | ||
| language = cls.setup_language_data(name=f"lang for {name}") |
There was a problem hiding this comment.
Function APIData.setup_item_pocket_name_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| item_pocket = item_pocket or cls.setup_item_pocket_data( | ||
| name="itm pkt for " + name | ||
| name=f"itm pkt for {name}" | ||
| ) | ||
|
|
There was a problem hiding this comment.
Function APIData.setup_item_category_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| language = cls.setup_language_data(name="lang for " + name) | ||
| language = cls.setup_language_data(name=f"lang for {name}") |
There was a problem hiding this comment.
Function APIData.setup_item_category_name_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| language = cls.setup_language_data(name="lang for " + name) | ||
| language = cls.setup_language_data(name=f"lang for {name}") |
There was a problem hiding this comment.
Function APIData.setup_item_name_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| language = cls.setup_language_data(name="lang for " + effect) | ||
| language = cls.setup_language_data(name=f"lang for {effect}") |
There was a problem hiding this comment.
Function APIData.setup_item_effect_text_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| version_group = cls.setup_version_group_data(name="ver grp for " + flavor_text) | ||
| version_group = cls.setup_version_group_data(name=f"ver grp for {flavor_text}") | ||
|
|
||
| language = cls.setup_language_data(name="lang for " + flavor_text) | ||
| language = cls.setup_language_data(name=f"lang for {flavor_text}") |
There was a problem hiding this comment.
Function APIData.setup_item_flavor_text_data refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
| language = cls.setup_language_data(name="lang for " + name) | ||
| language = cls.setup_language_data(name=f"lang for {name}") |
There was a problem hiding this comment.
Function APIData.setup_contest_type_name_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| language = cls.setup_language_data(name="lang for " + flavor_text) | ||
| language = cls.setup_language_data(name=f"lang for {flavor_text}") |
There was a problem hiding this comment.
Function APIData.setup_contest_effect_flavor_text_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| language = cls.setup_language_data(name="lang for " + name) | ||
| language = cls.setup_language_data(name=f"lang for {name}") |
There was a problem hiding this comment.
Function APIData.setup_location_area_name_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| name="mv dmg cls for " + name | ||
| name=f"mv dmg cls for {name}" | ||
| ) | ||
|
|
||
| generation = generation or cls.setup_generation_data(name="rgn for " + name) | ||
|
|
||
| generation = generation or cls.setup_generation_data(name=f"rgn for {name}") |
There was a problem hiding this comment.
Function APIData.setup_type_data refactored with the following changes:
- Use f-string instead of string concatenation [×2] (
use-fstring-for-concatenation)
| language = cls.setup_language_data(name="lang for " + name) | ||
| language = cls.setup_language_data(name=f"lang for {name}") |
There was a problem hiding this comment.
Function APIData.setup_type_name_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| language = cls.setup_language_data(name="lang for " + name) | ||
| language = cls.setup_language_data(name=f"lang for {name}") |
There was a problem hiding this comment.
Function APIData.setup_move_ailment_name_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| language = cls.setup_language_data(name="lang for " + name) | ||
| language = cls.setup_language_data(name=f"lang for {name}") |
There was a problem hiding this comment.
Function APIData.setup_move_battle_style_name_data refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: