From df103f6e9da1a2cf29a724aa5ac6cf90cf78d7a2 Mon Sep 17 00:00:00 2001 From: 201st-Luka Date: Wed, 23 Aug 2023 10:57:51 +0200 Subject: [PATCH 1/4] fix: `client.client_id` cannot be set to taken value fixed the bug which allowed to set multiple client ids to the same value --- pyclasher/client.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pyclasher/client.py b/pyclasher/client.py index 09b7986..47c59d0 100644 --- a/pyclasher/client.py +++ b/pyclasher/client.py @@ -189,9 +189,17 @@ def client_id(self): @client_id.setter def client_id(self, new_id): + global client_id + if isinstance(new_id, str) and new_id.isdigit(): + new_id = int(new_id) + if not isinstance(new_id, (int, str)): raise TypeError(f"Expected types int, str got {type(new_id)} " f"instead.") + for client in Client.__instances: + if client.client_id == new_id: + raise ValueError(f"`new_id` {new_id} has already been taken " + f"and must be different") self._client_id = new_id return From 6cce031113cc11eab4edfa5b7c6a71ae826577e4 Mon Sep 17 00:00:00 2001 From: 201st-Luka Date: Thu, 24 Aug 2023 09:04:39 +0200 Subject: [PATCH 2/4] fix: updated .editorconfig removed redundant types --- .editorconfig | 664 +------------------------------------------------- 1 file changed, 3 insertions(+), 661 deletions(-) diff --git a/.editorconfig b/.editorconfig index 0c636fe..08a6a95 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,120 +14,6 @@ ij_smart_tabs = false ij_visual_guides = ij_wrap_on_typing = false -[*.css] -ij_css_align_closing_brace_with_properties = false -ij_css_blank_lines_around_nested_selector = 1 -ij_css_blank_lines_between_blocks = 1 -ij_css_block_comment_add_space = false -ij_css_brace_placement = end_of_line -ij_css_enforce_quotes_on_format = false -ij_css_hex_color_long_format = false -ij_css_hex_color_lower_case = false -ij_css_hex_color_short_format = false -ij_css_hex_color_upper_case = false -ij_css_keep_blank_lines_in_code = 2 -ij_css_keep_indents_on_empty_lines = false -ij_css_keep_single_line_blocks = false -ij_css_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow -ij_css_space_after_colon = true -ij_css_space_before_opening_brace = true -ij_css_use_double_quotes = true -ij_css_value_alignment = do_not_align - -[*.feature] -indent_size = 2 -ij_gherkin_keep_indents_on_empty_lines = false - -[*.less] -indent_size = 2 -ij_less_align_closing_brace_with_properties = false -ij_less_blank_lines_around_nested_selector = 1 -ij_less_blank_lines_between_blocks = 1 -ij_less_block_comment_add_space = false -ij_less_brace_placement = 0 -ij_less_enforce_quotes_on_format = false -ij_less_hex_color_long_format = false -ij_less_hex_color_lower_case = false -ij_less_hex_color_short_format = false -ij_less_hex_color_upper_case = false -ij_less_keep_blank_lines_in_code = 2 -ij_less_keep_indents_on_empty_lines = false -ij_less_keep_single_line_blocks = false -ij_less_line_comment_add_space = false -ij_less_line_comment_at_first_column = false -ij_less_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow -ij_less_space_after_colon = true -ij_less_space_before_opening_brace = true -ij_less_use_double_quotes = true -ij_less_value_alignment = 0 - -[*.pp] -indent_size = 2 -tab_width = 2 -ij_continuation_indent_size = 2 -ij_puppet_keep_indents_on_empty_lines = false - -[*.properties] -ij_properties_align_group_field_declarations = false -ij_properties_keep_blank_lines = false -ij_properties_key_value_delimiter = equals -ij_properties_spaces_around_key_value_delimiter = false - -[*.sass] -indent_size = 2 -ij_sass_align_closing_brace_with_properties = false -ij_sass_blank_lines_around_nested_selector = 1 -ij_sass_blank_lines_between_blocks = 1 -ij_sass_brace_placement = 0 -ij_sass_enforce_quotes_on_format = false -ij_sass_hex_color_long_format = false -ij_sass_hex_color_lower_case = false -ij_sass_hex_color_short_format = false -ij_sass_hex_color_upper_case = false -ij_sass_keep_blank_lines_in_code = 2 -ij_sass_keep_indents_on_empty_lines = false -ij_sass_keep_single_line_blocks = false -ij_sass_line_comment_add_space = false -ij_sass_line_comment_at_first_column = false -ij_sass_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow -ij_sass_space_after_colon = true -ij_sass_space_before_opening_brace = true -ij_sass_use_double_quotes = true -ij_sass_value_alignment = 0 - -[*.scss] -indent_size = 2 -ij_scss_align_closing_brace_with_properties = false -ij_scss_blank_lines_around_nested_selector = 1 -ij_scss_blank_lines_between_blocks = 1 -ij_scss_block_comment_add_space = false -ij_scss_brace_placement = 0 -ij_scss_enforce_quotes_on_format = false -ij_scss_hex_color_long_format = false -ij_scss_hex_color_lower_case = false -ij_scss_hex_color_short_format = false -ij_scss_hex_color_upper_case = false -ij_scss_keep_blank_lines_in_code = 2 -ij_scss_keep_indents_on_empty_lines = false -ij_scss_keep_single_line_blocks = false -ij_scss_line_comment_add_space = false -ij_scss_line_comment_at_first_column = false -ij_scss_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow -ij_scss_space_after_colon = true -ij_scss_space_before_opening_brace = true -ij_scss_use_double_quotes = true -ij_scss_value_alignment = 0 - -[*.vue] -indent_size = 2 -tab_width = 2 -ij_continuation_indent_size = 4 -ij_vue_indent_children_of_top_level = template -ij_vue_interpolation_new_line_after_start_delimiter = true -ij_vue_interpolation_new_line_before_end_delimiter = true -ij_vue_interpolation_wrap = off -ij_vue_keep_indents_on_empty_lines = false -ij_vue_spaces_within_interpolation_expressions = true [.editorconfig] ij_editorconfig_align_group_field_declarations = false @@ -137,6 +23,7 @@ ij_editorconfig_space_before_colon = false ij_editorconfig_space_before_comma = false ij_editorconfig_spaces_around_assignment_operators = true + [{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}] ij_xml_align_attributes = true ij_xml_align_text = false @@ -156,178 +43,6 @@ ij_xml_space_around_equals_in_attribute = false ij_xml_space_inside_empty_tag = false ij_xml_text_wrap = normal -[{*.ats,*.cts,*.mts,*.ts}] -ij_continuation_indent_size = 4 -ij_typescript_align_imports = false -ij_typescript_align_multiline_array_initializer_expression = false -ij_typescript_align_multiline_binary_operation = false -ij_typescript_align_multiline_chained_methods = false -ij_typescript_align_multiline_extends_list = false -ij_typescript_align_multiline_for = true -ij_typescript_align_multiline_parameters = true -ij_typescript_align_multiline_parameters_in_calls = false -ij_typescript_align_multiline_ternary_operation = false -ij_typescript_align_object_properties = 0 -ij_typescript_align_union_types = false -ij_typescript_align_var_statements = 0 -ij_typescript_array_initializer_new_line_after_left_brace = false -ij_typescript_array_initializer_right_brace_on_new_line = false -ij_typescript_array_initializer_wrap = off -ij_typescript_assignment_wrap = off -ij_typescript_binary_operation_sign_on_next_line = false -ij_typescript_binary_operation_wrap = off -ij_typescript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/** -ij_typescript_blank_lines_after_imports = 1 -ij_typescript_blank_lines_around_class = 1 -ij_typescript_blank_lines_around_field = 0 -ij_typescript_blank_lines_around_field_in_interface = 0 -ij_typescript_blank_lines_around_function = 1 -ij_typescript_blank_lines_around_method = 1 -ij_typescript_blank_lines_around_method_in_interface = 1 -ij_typescript_block_brace_style = end_of_line -ij_typescript_block_comment_add_space = false -ij_typescript_block_comment_at_first_column = true -ij_typescript_call_parameters_new_line_after_left_paren = false -ij_typescript_call_parameters_right_paren_on_new_line = false -ij_typescript_call_parameters_wrap = off -ij_typescript_catch_on_new_line = false -ij_typescript_chained_call_dot_on_new_line = true -ij_typescript_class_brace_style = end_of_line -ij_typescript_comma_on_new_line = false -ij_typescript_do_while_brace_force = never -ij_typescript_else_on_new_line = false -ij_typescript_enforce_trailing_comma = keep -ij_typescript_enum_constants_wrap = on_every_item -ij_typescript_extends_keyword_wrap = off -ij_typescript_extends_list_wrap = off -ij_typescript_field_prefix = _ -ij_typescript_file_name_style = relaxed -ij_typescript_finally_on_new_line = false -ij_typescript_for_brace_force = never -ij_typescript_for_statement_new_line_after_left_paren = false -ij_typescript_for_statement_right_paren_on_new_line = false -ij_typescript_for_statement_wrap = off -ij_typescript_force_quote_style = false -ij_typescript_force_semicolon_style = false -ij_typescript_function_expression_brace_style = end_of_line -ij_typescript_if_brace_force = never -ij_typescript_import_merge_members = global -ij_typescript_import_prefer_absolute_path = global -ij_typescript_import_sort_members = true -ij_typescript_import_sort_module_name = false -ij_typescript_import_use_node_resolution = true -ij_typescript_imports_wrap = on_every_item -ij_typescript_indent_case_from_switch = true -ij_typescript_indent_chained_calls = true -ij_typescript_indent_package_children = 0 -ij_typescript_jsdoc_include_types = false -ij_typescript_jsx_attribute_value = braces -ij_typescript_keep_blank_lines_in_code = 2 -ij_typescript_keep_first_column_comment = true -ij_typescript_keep_indents_on_empty_lines = false -ij_typescript_keep_line_breaks = true -ij_typescript_keep_simple_blocks_in_one_line = false -ij_typescript_keep_simple_methods_in_one_line = false -ij_typescript_line_comment_add_space = true -ij_typescript_line_comment_at_first_column = false -ij_typescript_method_brace_style = end_of_line -ij_typescript_method_call_chain_wrap = off -ij_typescript_method_parameters_new_line_after_left_paren = false -ij_typescript_method_parameters_right_paren_on_new_line = false -ij_typescript_method_parameters_wrap = off -ij_typescript_object_literal_wrap = on_every_item -ij_typescript_object_types_wrap = on_every_item -ij_typescript_parentheses_expression_new_line_after_left_paren = false -ij_typescript_parentheses_expression_right_paren_on_new_line = false -ij_typescript_place_assignment_sign_on_next_line = false -ij_typescript_prefer_as_type_cast = false -ij_typescript_prefer_explicit_types_function_expression_returns = false -ij_typescript_prefer_explicit_types_function_returns = false -ij_typescript_prefer_explicit_types_vars_fields = false -ij_typescript_prefer_parameters_wrap = false -ij_typescript_property_prefix = -ij_typescript_reformat_c_style_comments = false -ij_typescript_space_after_colon = true -ij_typescript_space_after_comma = true -ij_typescript_space_after_dots_in_rest_parameter = false -ij_typescript_space_after_generator_mult = true -ij_typescript_space_after_property_colon = true -ij_typescript_space_after_quest = true -ij_typescript_space_after_type_colon = true -ij_typescript_space_after_unary_not = false -ij_typescript_space_before_async_arrow_lparen = true -ij_typescript_space_before_catch_keyword = true -ij_typescript_space_before_catch_left_brace = true -ij_typescript_space_before_catch_parentheses = true -ij_typescript_space_before_class_lbrace = true -ij_typescript_space_before_class_left_brace = true -ij_typescript_space_before_colon = true -ij_typescript_space_before_comma = false -ij_typescript_space_before_do_left_brace = true -ij_typescript_space_before_else_keyword = true -ij_typescript_space_before_else_left_brace = true -ij_typescript_space_before_finally_keyword = true -ij_typescript_space_before_finally_left_brace = true -ij_typescript_space_before_for_left_brace = true -ij_typescript_space_before_for_parentheses = true -ij_typescript_space_before_for_semicolon = false -ij_typescript_space_before_function_left_parenth = true -ij_typescript_space_before_generator_mult = false -ij_typescript_space_before_if_left_brace = true -ij_typescript_space_before_if_parentheses = true -ij_typescript_space_before_method_call_parentheses = false -ij_typescript_space_before_method_left_brace = true -ij_typescript_space_before_method_parentheses = false -ij_typescript_space_before_property_colon = false -ij_typescript_space_before_quest = true -ij_typescript_space_before_switch_left_brace = true -ij_typescript_space_before_switch_parentheses = true -ij_typescript_space_before_try_left_brace = true -ij_typescript_space_before_type_colon = false -ij_typescript_space_before_unary_not = false -ij_typescript_space_before_while_keyword = true -ij_typescript_space_before_while_left_brace = true -ij_typescript_space_before_while_parentheses = true -ij_typescript_spaces_around_additive_operators = true -ij_typescript_spaces_around_arrow_function_operator = true -ij_typescript_spaces_around_assignment_operators = true -ij_typescript_spaces_around_bitwise_operators = true -ij_typescript_spaces_around_equality_operators = true -ij_typescript_spaces_around_logical_operators = true -ij_typescript_spaces_around_multiplicative_operators = true -ij_typescript_spaces_around_relational_operators = true -ij_typescript_spaces_around_shift_operators = true -ij_typescript_spaces_around_unary_operator = false -ij_typescript_spaces_within_array_initializer_brackets = false -ij_typescript_spaces_within_brackets = false -ij_typescript_spaces_within_catch_parentheses = false -ij_typescript_spaces_within_for_parentheses = false -ij_typescript_spaces_within_if_parentheses = false -ij_typescript_spaces_within_imports = false -ij_typescript_spaces_within_interpolation_expressions = false -ij_typescript_spaces_within_method_call_parentheses = false -ij_typescript_spaces_within_method_parentheses = false -ij_typescript_spaces_within_object_literal_braces = false -ij_typescript_spaces_within_object_type_braces = true -ij_typescript_spaces_within_parentheses = false -ij_typescript_spaces_within_switch_parentheses = false -ij_typescript_spaces_within_type_assertion = false -ij_typescript_spaces_within_union_types = true -ij_typescript_spaces_within_while_parentheses = false -ij_typescript_special_else_if_treatment = true -ij_typescript_ternary_operation_signs_on_next_line = false -ij_typescript_ternary_operation_wrap = off -ij_typescript_union_types_wrap = on_every_item -ij_typescript_use_chained_calls_group_indents = false -ij_typescript_use_double_quotes = true -ij_typescript_use_explicit_js_extension = auto -ij_typescript_use_path_mapping = always -ij_typescript_use_public_modifier = false -ij_typescript_use_semicolon_after_statement = true -ij_typescript_var_declaration_wrap = normal -ij_typescript_while_brace_force = never -ij_typescript_while_on_new_line = false -ij_typescript_wrap_comments = false [{*.bash,*.sh,*.zsh}] indent_size = 2 @@ -339,176 +54,8 @@ ij_shell_redirect_followed_by_space = false ij_shell_switch_cases_indented = false ij_shell_use_unix_line_separator = true -[{*.cjs,*.js}] -ij_continuation_indent_size = 4 -ij_javascript_align_imports = false -ij_javascript_align_multiline_array_initializer_expression = false -ij_javascript_align_multiline_binary_operation = false -ij_javascript_align_multiline_chained_methods = false -ij_javascript_align_multiline_extends_list = false -ij_javascript_align_multiline_for = true -ij_javascript_align_multiline_parameters = true -ij_javascript_align_multiline_parameters_in_calls = false -ij_javascript_align_multiline_ternary_operation = false -ij_javascript_align_object_properties = 0 -ij_javascript_align_union_types = false -ij_javascript_align_var_statements = 0 -ij_javascript_array_initializer_new_line_after_left_brace = false -ij_javascript_array_initializer_right_brace_on_new_line = false -ij_javascript_array_initializer_wrap = off -ij_javascript_assignment_wrap = off -ij_javascript_binary_operation_sign_on_next_line = false -ij_javascript_binary_operation_wrap = off -ij_javascript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/** -ij_javascript_blank_lines_after_imports = 1 -ij_javascript_blank_lines_around_class = 1 -ij_javascript_blank_lines_around_field = 0 -ij_javascript_blank_lines_around_function = 1 -ij_javascript_blank_lines_around_method = 1 -ij_javascript_block_brace_style = end_of_line -ij_javascript_block_comment_add_space = false -ij_javascript_block_comment_at_first_column = true -ij_javascript_call_parameters_new_line_after_left_paren = false -ij_javascript_call_parameters_right_paren_on_new_line = false -ij_javascript_call_parameters_wrap = off -ij_javascript_catch_on_new_line = false -ij_javascript_chained_call_dot_on_new_line = true -ij_javascript_class_brace_style = end_of_line -ij_javascript_comma_on_new_line = false -ij_javascript_do_while_brace_force = never -ij_javascript_else_on_new_line = false -ij_javascript_enforce_trailing_comma = keep -ij_javascript_extends_keyword_wrap = off -ij_javascript_extends_list_wrap = off -ij_javascript_field_prefix = _ -ij_javascript_file_name_style = relaxed -ij_javascript_finally_on_new_line = false -ij_javascript_for_brace_force = never -ij_javascript_for_statement_new_line_after_left_paren = false -ij_javascript_for_statement_right_paren_on_new_line = false -ij_javascript_for_statement_wrap = off -ij_javascript_force_quote_style = false -ij_javascript_force_semicolon_style = false -ij_javascript_function_expression_brace_style = end_of_line -ij_javascript_if_brace_force = never -ij_javascript_import_merge_members = global -ij_javascript_import_prefer_absolute_path = global -ij_javascript_import_sort_members = true -ij_javascript_import_sort_module_name = false -ij_javascript_import_use_node_resolution = true -ij_javascript_imports_wrap = on_every_item -ij_javascript_indent_case_from_switch = true -ij_javascript_indent_chained_calls = true -ij_javascript_indent_package_children = 0 -ij_javascript_jsx_attribute_value = braces -ij_javascript_keep_blank_lines_in_code = 2 -ij_javascript_keep_first_column_comment = true -ij_javascript_keep_indents_on_empty_lines = false -ij_javascript_keep_line_breaks = true -ij_javascript_keep_simple_blocks_in_one_line = false -ij_javascript_keep_simple_methods_in_one_line = false -ij_javascript_line_comment_add_space = true -ij_javascript_line_comment_at_first_column = false -ij_javascript_method_brace_style = end_of_line -ij_javascript_method_call_chain_wrap = off -ij_javascript_method_parameters_new_line_after_left_paren = false -ij_javascript_method_parameters_right_paren_on_new_line = false -ij_javascript_method_parameters_wrap = off -ij_javascript_object_literal_wrap = on_every_item -ij_javascript_object_types_wrap = on_every_item -ij_javascript_parentheses_expression_new_line_after_left_paren = false -ij_javascript_parentheses_expression_right_paren_on_new_line = false -ij_javascript_place_assignment_sign_on_next_line = false -ij_javascript_prefer_as_type_cast = false -ij_javascript_prefer_explicit_types_function_expression_returns = false -ij_javascript_prefer_explicit_types_function_returns = false -ij_javascript_prefer_explicit_types_vars_fields = false -ij_javascript_prefer_parameters_wrap = false -ij_javascript_property_prefix = -ij_javascript_reformat_c_style_comments = false -ij_javascript_space_after_colon = true -ij_javascript_space_after_comma = true -ij_javascript_space_after_dots_in_rest_parameter = false -ij_javascript_space_after_generator_mult = true -ij_javascript_space_after_property_colon = true -ij_javascript_space_after_quest = true -ij_javascript_space_after_type_colon = true -ij_javascript_space_after_unary_not = false -ij_javascript_space_before_async_arrow_lparen = true -ij_javascript_space_before_catch_keyword = true -ij_javascript_space_before_catch_left_brace = true -ij_javascript_space_before_catch_parentheses = true -ij_javascript_space_before_class_lbrace = true -ij_javascript_space_before_class_left_brace = true -ij_javascript_space_before_colon = true -ij_javascript_space_before_comma = false -ij_javascript_space_before_do_left_brace = true -ij_javascript_space_before_else_keyword = true -ij_javascript_space_before_else_left_brace = true -ij_javascript_space_before_finally_keyword = true -ij_javascript_space_before_finally_left_brace = true -ij_javascript_space_before_for_left_brace = true -ij_javascript_space_before_for_parentheses = true -ij_javascript_space_before_for_semicolon = false -ij_javascript_space_before_function_left_parenth = true -ij_javascript_space_before_generator_mult = false -ij_javascript_space_before_if_left_brace = true -ij_javascript_space_before_if_parentheses = true -ij_javascript_space_before_method_call_parentheses = false -ij_javascript_space_before_method_left_brace = true -ij_javascript_space_before_method_parentheses = false -ij_javascript_space_before_property_colon = false -ij_javascript_space_before_quest = true -ij_javascript_space_before_switch_left_brace = true -ij_javascript_space_before_switch_parentheses = true -ij_javascript_space_before_try_left_brace = true -ij_javascript_space_before_type_colon = false -ij_javascript_space_before_unary_not = false -ij_javascript_space_before_while_keyword = true -ij_javascript_space_before_while_left_brace = true -ij_javascript_space_before_while_parentheses = true -ij_javascript_spaces_around_additive_operators = true -ij_javascript_spaces_around_arrow_function_operator = true -ij_javascript_spaces_around_assignment_operators = true -ij_javascript_spaces_around_bitwise_operators = true -ij_javascript_spaces_around_equality_operators = true -ij_javascript_spaces_around_logical_operators = true -ij_javascript_spaces_around_multiplicative_operators = true -ij_javascript_spaces_around_relational_operators = true -ij_javascript_spaces_around_shift_operators = true -ij_javascript_spaces_around_unary_operator = false -ij_javascript_spaces_within_array_initializer_brackets = false -ij_javascript_spaces_within_brackets = false -ij_javascript_spaces_within_catch_parentheses = false -ij_javascript_spaces_within_for_parentheses = false -ij_javascript_spaces_within_if_parentheses = false -ij_javascript_spaces_within_imports = false -ij_javascript_spaces_within_interpolation_expressions = false -ij_javascript_spaces_within_method_call_parentheses = false -ij_javascript_spaces_within_method_parentheses = false -ij_javascript_spaces_within_object_literal_braces = false -ij_javascript_spaces_within_object_type_braces = true -ij_javascript_spaces_within_parentheses = false -ij_javascript_spaces_within_switch_parentheses = false -ij_javascript_spaces_within_type_assertion = false -ij_javascript_spaces_within_union_types = true -ij_javascript_spaces_within_while_parentheses = false -ij_javascript_special_else_if_treatment = true -ij_javascript_ternary_operation_signs_on_next_line = false -ij_javascript_ternary_operation_wrap = off -ij_javascript_union_types_wrap = on_every_item -ij_javascript_use_chained_calls_group_indents = false -ij_javascript_use_double_quotes = true -ij_javascript_use_explicit_js_extension = auto -ij_javascript_use_path_mapping = always -ij_javascript_use_public_modifier = false -ij_javascript_use_semicolon_after_statement = true -ij_javascript_var_declaration_wrap = normal -ij_javascript_while_brace_force = never -ij_javascript_while_on_new_line = false -ij_javascript_wrap_comments = false -[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config}] +[*.json] indent_size = 2 ij_json_array_wrapping = split_into_lines ij_json_keep_blank_lines_in_code = 0 @@ -525,41 +72,6 @@ ij_json_spaces_within_braces = false ij_json_spaces_within_brackets = false ij_json_wrap_long_lines = false -[{*.htm,*.html,*.ng,*.sht,*.shtm,*.shtml}] -ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3 -ij_html_align_attributes = true -ij_html_align_text = false -ij_html_attribute_wrap = normal -ij_html_block_comment_add_space = false -ij_html_block_comment_at_first_column = true -ij_html_do_not_align_children_of_min_lines = 0 -ij_html_do_not_break_if_inline_tags = title,h1,h2,h3,h4,h5,h6,p -ij_html_do_not_indent_children_of_tags = html,body,thead,tbody,tfoot -ij_html_enforce_quotes = false -ij_html_inline_tags = a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var -ij_html_keep_blank_lines = 2 -ij_html_keep_indents_on_empty_lines = false -ij_html_keep_line_breaks = true -ij_html_keep_line_breaks_in_text = true -ij_html_keep_whitespaces = false -ij_html_keep_whitespaces_inside = span,pre,textarea -ij_html_line_comment_at_first_column = true -ij_html_new_line_after_last_attribute = never -ij_html_new_line_before_first_attribute = never -ij_html_quote_style = double -ij_html_remove_new_line_before_tags = br -ij_html_space_after_tag_name = false -ij_html_space_around_equality_in_attribute = false -ij_html_space_inside_empty_tag = false -ij_html_text_wrap = normal - -[{*.http,*.rest}] -indent_size = 0 -ij_continuation_indent_size = 4 -ij_http-request_call_parameters_wrap = normal -ij_http-request_method_parameters_wrap = split_into_lines -ij_http-request_space_before_comma = true -ij_http-request_spaces_around_assignment_operators = true [{*.markdown,*.md}] ij_markdown_force_one_space_after_blockquote_symbol = true @@ -579,6 +91,7 @@ ij_markdown_min_lines_between_paragraphs = 1 ij_markdown_wrap_text_if_long = true ij_markdown_wrap_text_inside_blockquotes = true + [{*.py,*.pyw}] ij_wrap_on_typing = true ij_python_align_collections_and_comprehensions = true @@ -652,177 +165,6 @@ ij_python_use_continuation_indent_for_collection_and_comprehensions = false ij_python_use_continuation_indent_for_parameters = true ij_python_wrap_long_lines = false -[{*.qml,*.qmltypes}] -ij_continuation_indent_size = 4 -ij_qmllang_align_imports = false -ij_qmllang_align_multiline_array_initializer_expression = false -ij_qmllang_align_multiline_binary_operation = false -ij_qmllang_align_multiline_chained_methods = false -ij_qmllang_align_multiline_extends_list = false -ij_qmllang_align_multiline_for = true -ij_qmllang_align_multiline_parameters = true -ij_qmllang_align_multiline_parameters_in_calls = false -ij_qmllang_align_multiline_ternary_operation = false -ij_qmllang_align_object_properties = 0 -ij_qmllang_align_union_types = false -ij_qmllang_align_var_statements = 0 -ij_qmllang_array_initializer_new_line_after_left_brace = false -ij_qmllang_array_initializer_right_brace_on_new_line = false -ij_qmllang_array_initializer_wrap = off -ij_qmllang_assignment_wrap = off -ij_qmllang_binary_operation_sign_on_next_line = false -ij_qmllang_binary_operation_wrap = off -ij_qmllang_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/** -ij_qmllang_blank_lines_after_imports = 1 -ij_qmllang_blank_lines_around_class = 1 -ij_qmllang_blank_lines_around_field = 0 -ij_qmllang_blank_lines_around_function = 1 -ij_qmllang_blank_lines_around_method = 1 -ij_qmllang_block_brace_style = end_of_line -ij_qmllang_block_comment_add_space = false -ij_qmllang_block_comment_at_first_column = true -ij_qmllang_call_parameters_new_line_after_left_paren = false -ij_qmllang_call_parameters_right_paren_on_new_line = false -ij_qmllang_call_parameters_wrap = off -ij_qmllang_catch_on_new_line = false -ij_qmllang_chained_call_dot_on_new_line = true -ij_qmllang_class_brace_style = end_of_line -ij_qmllang_comma_on_new_line = false -ij_qmllang_do_while_brace_force = never -ij_qmllang_else_on_new_line = false -ij_qmllang_enforce_trailing_comma = keep -ij_qmllang_extends_keyword_wrap = off -ij_qmllang_extends_list_wrap = off -ij_qmllang_field_prefix = _ -ij_qmllang_file_name_style = relaxed -ij_qmllang_finally_on_new_line = false -ij_qmllang_for_brace_force = never -ij_qmllang_for_statement_new_line_after_left_paren = false -ij_qmllang_for_statement_right_paren_on_new_line = false -ij_qmllang_for_statement_wrap = off -ij_qmllang_force_quote_style = false -ij_qmllang_force_semicolon_style = false -ij_qmllang_function_expression_brace_style = end_of_line -ij_qmllang_if_brace_force = never -ij_qmllang_import_merge_members = global -ij_qmllang_import_prefer_absolute_path = global -ij_qmllang_import_sort_members = true -ij_qmllang_import_sort_module_name = false -ij_qmllang_import_use_node_resolution = true -ij_qmllang_imports_wrap = on_every_item -ij_qmllang_indent_case_from_switch = true -ij_qmllang_indent_chained_calls = true -ij_qmllang_indent_package_children = 0 -ij_qmllang_jsx_attribute_value = braces -ij_qmllang_keep_blank_lines_in_code = 2 -ij_qmllang_keep_first_column_comment = true -ij_qmllang_keep_indents_on_empty_lines = false -ij_qmllang_keep_line_breaks = true -ij_qmllang_keep_simple_blocks_in_one_line = false -ij_qmllang_keep_simple_methods_in_one_line = false -ij_qmllang_line_comment_add_space = true -ij_qmllang_line_comment_at_first_column = false -ij_qmllang_method_brace_style = end_of_line -ij_qmllang_method_call_chain_wrap = off -ij_qmllang_method_parameters_new_line_after_left_paren = false -ij_qmllang_method_parameters_right_paren_on_new_line = false -ij_qmllang_method_parameters_wrap = off -ij_qmllang_object_literal_wrap = on_every_item -ij_qmllang_object_types_wrap = on_every_item -ij_qmllang_parentheses_expression_new_line_after_left_paren = false -ij_qmllang_parentheses_expression_right_paren_on_new_line = false -ij_qmllang_place_assignment_sign_on_next_line = false -ij_qmllang_prefer_as_type_cast = false -ij_qmllang_prefer_explicit_types_function_expression_returns = false -ij_qmllang_prefer_explicit_types_function_returns = false -ij_qmllang_prefer_explicit_types_vars_fields = false -ij_qmllang_prefer_parameters_wrap = false -ij_qmllang_property_prefix = -ij_qmllang_reformat_c_style_comments = false -ij_qmllang_space_after_colon = true -ij_qmllang_space_after_comma = true -ij_qmllang_space_after_dots_in_rest_parameter = false -ij_qmllang_space_after_generator_mult = true -ij_qmllang_space_after_property_colon = true -ij_qmllang_space_after_quest = true -ij_qmllang_space_after_type_colon = true -ij_qmllang_space_after_unary_not = false -ij_qmllang_space_before_async_arrow_lparen = true -ij_qmllang_space_before_catch_keyword = true -ij_qmllang_space_before_catch_left_brace = true -ij_qmllang_space_before_catch_parentheses = true -ij_qmllang_space_before_class_lbrace = true -ij_qmllang_space_before_class_left_brace = true -ij_qmllang_space_before_colon = true -ij_qmllang_space_before_comma = false -ij_qmllang_space_before_do_left_brace = true -ij_qmllang_space_before_else_keyword = true -ij_qmllang_space_before_else_left_brace = true -ij_qmllang_space_before_finally_keyword = true -ij_qmllang_space_before_finally_left_brace = true -ij_qmllang_space_before_for_left_brace = true -ij_qmllang_space_before_for_parentheses = true -ij_qmllang_space_before_for_semicolon = false -ij_qmllang_space_before_function_left_parenth = true -ij_qmllang_space_before_generator_mult = false -ij_qmllang_space_before_if_left_brace = true -ij_qmllang_space_before_if_parentheses = true -ij_qmllang_space_before_method_call_parentheses = false -ij_qmllang_space_before_method_left_brace = true -ij_qmllang_space_before_method_parentheses = false -ij_qmllang_space_before_property_colon = false -ij_qmllang_space_before_quest = true -ij_qmllang_space_before_switch_left_brace = true -ij_qmllang_space_before_switch_parentheses = true -ij_qmllang_space_before_try_left_brace = true -ij_qmllang_space_before_type_colon = false -ij_qmllang_space_before_unary_not = false -ij_qmllang_space_before_while_keyword = true -ij_qmllang_space_before_while_left_brace = true -ij_qmllang_space_before_while_parentheses = true -ij_qmllang_spaces_around_additive_operators = true -ij_qmllang_spaces_around_arrow_function_operator = true -ij_qmllang_spaces_around_assignment_operators = true -ij_qmllang_spaces_around_bitwise_operators = true -ij_qmllang_spaces_around_equality_operators = true -ij_qmllang_spaces_around_logical_operators = true -ij_qmllang_spaces_around_multiplicative_operators = true -ij_qmllang_spaces_around_relational_operators = true -ij_qmllang_spaces_around_shift_operators = true -ij_qmllang_spaces_around_unary_operator = false -ij_qmllang_spaces_within_array_initializer_brackets = false -ij_qmllang_spaces_within_brackets = false -ij_qmllang_spaces_within_catch_parentheses = false -ij_qmllang_spaces_within_for_parentheses = false -ij_qmllang_spaces_within_if_parentheses = false -ij_qmllang_spaces_within_imports = false -ij_qmllang_spaces_within_interpolation_expressions = false -ij_qmllang_spaces_within_method_call_parentheses = false -ij_qmllang_spaces_within_method_parentheses = false -ij_qmllang_spaces_within_object_literal_braces = false -ij_qmllang_spaces_within_object_type_braces = true -ij_qmllang_spaces_within_parentheses = false -ij_qmllang_spaces_within_switch_parentheses = false -ij_qmllang_spaces_within_type_assertion = false -ij_qmllang_spaces_within_union_types = true -ij_qmllang_spaces_within_while_parentheses = false -ij_qmllang_special_else_if_treatment = true -ij_qmllang_ternary_operation_signs_on_next_line = false -ij_qmllang_ternary_operation_wrap = off -ij_qmllang_union_types_wrap = on_every_item -ij_qmllang_use_chained_calls_group_indents = false -ij_qmllang_use_double_quotes = true -ij_qmllang_use_explicit_js_extension = auto -ij_qmllang_use_path_mapping = always -ij_qmllang_use_public_modifier = false -ij_qmllang_use_semicolon_after_statement = true -ij_qmllang_var_declaration_wrap = normal -ij_qmllang_while_brace_force = never -ij_qmllang_while_on_new_line = false -ij_qmllang_wrap_comments = false - -[{*.toml,Cargo.lock,Cargo.toml.orig,Gopkg.lock,Pipfile,poetry.lock}] -ij_toml_keep_indents_on_empty_lines = false [{*.yaml,*.yml}] indent_size = 2 From 7b93e7ae9aa6cacf976ec31834df42bfe0e4209e Mon Sep 17 00:00:00 2001 From: 201st-Luka Date: Thu, 24 Aug 2023 09:37:09 +0200 Subject: [PATCH 3/4] style: fixed some typos and intents --- pyclasher/__init__.py | 10 ++- .../api/bulk_requests/b_request_model.py | 16 +++- pyclasher/api/models/__init__.py | 73 +++++++++++++------ pyclasher/api/models/abc.py | 22 ++++-- pyclasher/api/models/base_models.py | 60 ++++++++++----- pyclasher/api/models/player.py | 24 ++++-- pyclasher/api/requests/abc.pyi | 6 +- .../api/requests/builder_base_leagues.py | 4 +- .../api/requests/builder_base_leagues.pyi | 3 - pyclasher/api/requests/clan.py | 2 - pyclasher/api/requests/clan_current_war.py | 2 - pyclasher/api/requests/clan_current_war.pyi | 2 - .../requests/clan_currentwar_leaguegroup.py | 2 - pyclasher/api/requests/clan_rankings.py | 3 +- pyclasher/api/requests/clan_search.py | 10 ++- pyclasher/api/requests/league_season.py | 7 +- pyclasher/api/requests/player.py | 6 +- pyclasher/api/requests/player.pyi | 2 - .../requests/player_builder_base_rankings.py | 3 +- pyclasher/api/requests/player_rankings.py | 3 +- pyclasher/client.py | 13 ++-- pyclasher/client.pyi | 2 +- pyclasher/exceptions.py | 22 ++++-- pyclasher/request_queue/request_consumer.py | 14 +++- pyclasher/request_queue/request_queue.py | 12 ++- pyclasher/utils/__init__.py | 2 + pyclasher/utils/login.py | 4 +- pyclasher/utils/login.pyi | 12 +-- setup.py | 3 +- tests/requests/conftest.py | 3 +- tests/requests/test_player.py | 2 +- 31 files changed, 231 insertions(+), 118 deletions(-) diff --git a/pyclasher/__init__.py b/pyclasher/__init__.py index ec4c49c..c628983 100644 --- a/pyclasher/__init__.py +++ b/pyclasher/__init__.py @@ -21,6 +21,10 @@ from .client import Client # exceptions.py -from .exceptions import (Missing, MISSING, PyClasherException, ApiCode, RequestNotDone, NoneToken, InvalidLoginData, - InvalidType, LoginNotDone, ClientIsRunning, ClientIsNotRunning, ClientAlreadyInitialised, - NoClient, InvalidTimeFormat, ClientRunningOverwrite, InvalidSeasonFormat, RequestTimeout) +from .exceptions import ( + Missing, MISSING, PyClasherException, ApiCode, RequestNotDone, NoneToken, + InvalidLoginData, InvalidType, LoginNotDone, ClientIsRunning, + ClientIsNotRunning, ClientAlreadyInitialised, NoClient, + InvalidTimeFormat, ClientRunningOverwrite, InvalidSeasonFormat, + RequestTimeout +) diff --git a/pyclasher/api/bulk_requests/b_request_model.py b/pyclasher/api/bulk_requests/b_request_model.py index 817a315..091236e 100644 --- a/pyclasher/api/bulk_requests/b_request_model.py +++ b/pyclasher/api/bulk_requests/b_request_model.py @@ -15,7 +15,11 @@ def requests(self): return self._requests def __get_properties(self): - return {name: prop.__get__(self) for name, prop in vars(self.__class__).items() if isinstance(prop, property)} + return { + name: prop.__get__(self) + for name, prop in vars(self.__class__).items() + if isinstance(prop, property) + } async def _async_request(self): self._tasks = [request.request() for request in self._requests] @@ -38,7 +42,8 @@ def __getitem__(self, item): if isinstance(item, int): return self._requests[item] if isinstance(item, slice): - return (self._requests[i] for i in range(*item.indices(len(self._requests)))) + return (self._requests[i] + for i in range(*item.indices(len(self._requests)))) raise NotImplementedError def __iter__(self): @@ -52,5 +57,8 @@ def __str__(self): return f"{self.__class__.__name__}({self._main_attribute})" def __repr__(self): - return (f"{self.__class__.__name__}" - f"({', '.join(('='.join((key, str(value))) for key, value in self.__get_properties().items()))})") + props = ', '.join( + ('='.join((key, str(value))) + for key, value in self.__get_properties().items()) + ) + return f"{self.__class__.__name__}({props})" diff --git a/pyclasher/api/models/__init__.py b/pyclasher/api/models/__init__.py index 366fcc3..771db0f 100644 --- a/pyclasher/api/models/__init__.py +++ b/pyclasher/api/models/__init__.py @@ -4,48 +4,79 @@ # abc from .abc import BaseModel, IterBaseModel # base models, miscellaneous models and enums -from .base_models import ImageUrl, IconUrl, IconUrls, After, Before, \ - Cursor, Paging, BadgeUrl, BadgeUrls, Time, BaseClanMember, BaseClan, BaseLeague +from .base_models import ( + ImageUrl, IconUrl, IconUrls, After, Before, + Cursor, Paging, BadgeUrl, BadgeUrls, Time, + BaseClanMember, BaseClan, + BaseLeague +) # clan models from .clan import ClanDistrictData, ClanDistrictDataList, ClanCapital, Clan -from .clan_builder_base_ranking_list import ClanBuilderBaseRanking, ClanBuilderBaseRankingList -from .clan_capital_raid_seasons import ClanCapitalRaidSeasonClanInfo, ClanCapitalRaidSeasonAttacker, \ - ClanCapitalRaidSeasonAttack, ClanCapitalRaidSeasonAttackList, ClanCapitalRaidSeasonDistrict, \ - ClanCapitalRaidSeasonDistrictList, ClanCapitalRaidSeasonDefenseLogEntry, ClanCapitalRaidSeasonAttackLogEntry, \ - ClanCapitalRaidSeasonDefenseLogList, ClanCapitalRaidSeasonAttackLogList, ClanCapitalRaidSeasonMember, \ - ClanCapitalRaidSeasonMemberList, ClanCapitalRaidSeason, ClanCapitalRaidSeasons -from .clan_capital_ranking_list import ClanCapitalRanking, ClanCapitalRankingList +from .clan_builder_base_ranking_list import ( + ClanBuilderBaseRanking, ClanBuilderBaseRankingList +) +from .clan_capital_raid_seasons import ( + ClanCapitalRaidSeasonClanInfo, ClanCapitalRaidSeasonAttacker, + ClanCapitalRaidSeasonAttack, ClanCapitalRaidSeasonAttackList, + ClanCapitalRaidSeasonDistrict, ClanCapitalRaidSeasonDistrictList, + ClanCapitalRaidSeasonDefenseLogEntry, + ClanCapitalRaidSeasonAttackLogEntry, ClanCapitalRaidSeasonDefenseLogList, + ClanCapitalRaidSeasonAttackLogList, ClanCapitalRaidSeasonMember, + ClanCapitalRaidSeasonMemberList, ClanCapitalRaidSeason, + ClanCapitalRaidSeasons +) +from .clan_capital_ranking_list import ( + ClanCapitalRanking, ClanCapitalRankingList +) from .clan_list import ClanList from .clan_member import ClanMember from .clan_member_list import ClanMemberList from .clan_ranking_list import ClanRanking, ClanRankingList from .clan_war import ClanWar -from .clan_war_league_group import ClanWarLeagueRound, ClanWarLeagueRoundList, ClanWarLeagueClanMember, \ - ClanWarLeagueClanMemberList, ClanWarLeagueClan, ClanWarLeagueClanList, ClanWarLeagueGroup +from .clan_war_league_group import ( + ClanWarLeagueRound, ClanWarLeagueRoundList, ClanWarLeagueClanMember, + ClanWarLeagueClanMemberList, ClanWarLeagueClan, ClanWarLeagueClanList, + ClanWarLeagueGroup +) from .clan_war_log import ClanWarLogEntry, ClanWarLog -from .enums import ApiCodes, ClanType, WarFrequency, Locations, Leagues, CapitalLeagues, \ - BuilderBaseLeagues, WarLeagues, Labels, Languages, ClanWarState, ClanWarLeagueGroupState, \ - ClanWarResult, WarPreference, PlayerHouseElementType, Village, TokenStatus, ClanRole +from .enums import ( + ApiCodes, ClanType, WarFrequency, Locations, Leagues, CapitalLeagues, + BuilderBaseLeagues, WarLeagues, Labels, Languages, ClanWarState, + ClanWarLeagueGroupState, ClanWarResult, WarPreference, + PlayerHouseElementType, Village, TokenStatus, ClanRole +) # gold pass season from .gold_pass_season import GoldPassSeason # labels from .labels import Label, LabelList from .language import Language # league models -from .leagues import League, BuilderBaseLeague, CapitalLeague, WarLeague, LeagueList, \ - BuilderBaseLeagueList, CapitalLeagueList, WarLeagueList, LeagueSeason, LeagueSeasonList +from .leagues import ( + League, BuilderBaseLeague, CapitalLeague, WarLeague, LeagueList, + BuilderBaseLeagueList, CapitalLeagueList, WarLeagueList, LeagueSeason, + LeagueSeasonList +) # locations from .location import Location, LocationList # login from .login import * from .misc import * # player models -from .player import PlayerClan, LegendLeagueTournamentSeasonResult, PlayerLegendStatistics, \ - PlayerItemLevel, PlayerItemLevelList, PlayerAchievementProgress, PlayerAchievementProgressList, Player -from .player_builder_base_ranking_list import PlayerBuilderBaseRanking, PlayerBuilderBaseRankingList -from .player_house import PlayerHouseElement, PlayerHouseElementList, PlayerHouse +from .player import ( + PlayerClan, LegendLeagueTournamentSeasonResult, PlayerLegendStatistics, + PlayerItemLevel, PlayerItemLevelList, PlayerAchievementProgress, + PlayerAchievementProgressList, Player +) +from .player_builder_base_ranking_list import ( + PlayerBuilderBaseRanking, PlayerBuilderBaseRankingList +) +from .player_house import ( + PlayerHouseElement, PlayerHouseElementList, PlayerHouse +) from .player_ranking_clan import PlayerRankingClan from .player_ranking_list import PlayerRanking, PlayerRankingList # misc from .season import Season -from .war_clan import ClanWarAttack, ClanWarAttackList, ClanWarMember, ClanWarMemberList, WarClan +from .war_clan import ( + ClanWarAttack, ClanWarAttackList, ClanWarMember, ClanWarMemberList, WarClan +) diff --git a/pyclasher/api/models/abc.py b/pyclasher/api/models/abc.py index 3d767cf..02fd0a7 100644 --- a/pyclasher/api/models/abc.py +++ b/pyclasher/api/models/abc.py @@ -20,7 +20,11 @@ def to_dict(self): def _get_properties(self): if isinstance(self._data, dict): - return {name: prop.__get__(self) for name, prop in vars(type(self)).items() if isinstance(prop, property)} + return { + name: prop.__get__(self) + for name, prop in vars(type(self)).items() + if isinstance(prop, property) + } return self._data def _get_data(self, item): @@ -39,8 +43,11 @@ def __str__(self): return f"{self.__class__.__name__}()" def __repr__(self): - return (f"{self.__class__.__name__}" - f"({', '.join(('='.join((key, str(value))) for key, value in self._get_properties().items()))})") + props = ', '.join( + ('='.join((key, str(value))) + for key, value in self._get_properties().items()) + ) + return f"{self.__class__.__name__}({props})" class IterBaseModel(ABC): @@ -72,8 +79,10 @@ def __getitem__(self, item): if isinstance(item, int): return self._iter_rtype(self._data[item]) if isinstance(item, slice): - return (self._iter_rtype(self._data[i]) for i in range(*item.indices(len(self._data)))) - raise NotImplementedError(f"there is no implementation for type {item.__class__.__name__} in " + return (self._iter_rtype(self._data[i]) + for i in range(*item.indices(len(self._data)))) + raise NotImplementedError(f"there is no implementation for type " + f"{item.__class__.__name__} in " f"{self.__class__.__name__}.__getitem__()") def __iter__(self): @@ -95,7 +104,8 @@ def __str__(self): return f"{self.__class__.__name__}()" def __repr__(self): - return f"{self.__class__.__name__}(len={self._len}, type={self._iter_rtype.__name__}, {list(self)})" + return (f"{self.__class__.__name__}(len={self._len}, type=" + f"{self._iter_rtype.__name__}, {list(self)})") diff --git a/pyclasher/api/models/base_models.py b/pyclasher/api/models/base_models.py index 63eb13e..6ab8327 100644 --- a/pyclasher/api/models/base_models.py +++ b/pyclasher/api/models/base_models.py @@ -169,15 +169,22 @@ def from_str(cls, time): except ValueError: raise InvalidTimeFormat(time, cls.time_format) - return cls(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.microsecond) + return cls( + dt.year, dt.month, dt.day, + dt.hour, dt.minute, dt.second, dt.microsecond + ) def __eq__(self, other): if isinstance(other, Time): - return self._year == other._year and self._month == other._month and self._day == other._day and \ - self._hour == other._hour and self._minute == other._minute and self._second == other._second + return (self._year == other._year and self._month == other._month + and self._day == other._day and + self._hour == other._hour and self._minute == other._minute + and self._second == other._second) if isinstance(other, (Time, datetime)): - return self._year == other.year and self._month == other.month and self._day == other.day and \ - self._hour == other.hour and self._minute == other.minute and self._second == other.second + return (self._year == other.year and self._month == other.month + and self._day == other.day and + self._hour == other.hour and self._minute == other.minute + and self._second == other.second) return NotImplemented def __ne__(self, other): @@ -189,19 +196,26 @@ def __lt__(self, other): return True if self._year == other.year and self._month < other.month: return True - if self._year == other.year and self._month == other.month and self._day < other.day: + if (self._year == other.year and self._month == other.month + and self._day < other.day): return True - if (self._year == other.year and self._month == other.month and self._day == other.day + if (self._year == other.year and self._month == other.month + and self._day == other.day and self._hour < other.hour): return True - if (self._year == other.year and self._month == other.month and self._day == other.day - and self._hour == other.hour and self._minute < other.minute): + if (self._year == other.year and self._month == other.month + and self._day == other.day and self._hour == other.hour + and self._minute < other.minute): return True - if (self._year == other.year and self._month == other.month and self._day == other.day - and self._hour == other.hour and self._minute == other.minute and self._second < other.second): + if (self._year == other.year and self._month == other.month + and self._day == other.day and self._hour == other.hour + and self._minute == other.minute + and self._second < other.second): return True - if (self._year == other.year and self._month == other.month and self._day == other.day - and self._hour == other.hour and self._minute == other.minute and self._second == other.second + if (self._year == other.year and self._month == other.month + and self._day == other.day and self._hour == other.hour + and self._minute == other.minute + and self._second == other.second and self._microsecond < other.microsecond): return True return False @@ -218,23 +232,29 @@ def __ge__(self, other): def __str__(self): return (f"Time({self._year}.{self._month}.{self._day}:" - f"{self._hour}.{self._minute}.{self._second}.{self._microsecond})") + f"{self._hour}.{self._minute}.{self._second}" + f".{self._microsecond})") def __repr__(self): - return (f"Time(year={self._year}, month={self._month}, day={self._day}, " - f"hour={self._hour}, minute={self._minute}, second={self._second}, microsecond={self._microsecond})") + return (f"Time(year={self._year}, month={self._month}, day={self._day}," + f" hour={self._hour}, minute={self._minute}, " + f"second={self._second}, microsecond={self._microsecond})") def __add__(self, other): if isinstance(other, (Time, datetime)): - return Time(self._year + other.year, self._month + other.month, self._day + other.day, - self._hour + other.hour, self._minute + other.minute, self._second + other.second, + return Time(self._year + other.year, self._month + other.month, + self._day + other.day, self._hour + other.hour, + self._minute + other.minute, + self._second + other.second, self._microsecond + other.microsecond) return NotImplemented def __sub__(self, other): if isinstance(other, (Time, datetime)): - return Time(self._year - other.year, self._month - other.month, self._day - other.day, - self._hour - other.hour, self._minute - other.minute, self._second - other.second, + return Time(self._year - other.year, self._month - other.month, + self._day - other.day, self._hour - other.hour, + self._minute - other.minute, + self._second - other.second, self._microsecond - other.microsecond) return NotImplemented diff --git a/pyclasher/api/models/player.py b/pyclasher/api/models/player.py index b5eb8c5..c4b9669 100644 --- a/pyclasher/api/models/player.py +++ b/pyclasher/api/models/player.py @@ -38,27 +38,39 @@ def best_season(self): @property def current_season(self): - return LegendLeagueTournamentSeasonResult(self._get_data('currentSeason')) + return LegendLeagueTournamentSeasonResult( + self._get_data('currentSeason') + ) @property def previous_season(self): - return LegendLeagueTournamentSeasonResult(self._get_data('previousSeason')) + return LegendLeagueTournamentSeasonResult( + self._get_data('previousSeason') + ) @property def previous_builder_base_season(self): - return LegendLeagueTournamentSeasonResult(self._get_data('previousBuilderBaseSeason')) + return LegendLeagueTournamentSeasonResult( + self._get_data('previousBuilderBaseSeason') + ) @property def previous_versus_season(self): - return LegendLeagueTournamentSeasonResult(self._get_data('previousVersusSeason')) + return LegendLeagueTournamentSeasonResult( + self._get_data('previousVersusSeason') + ) @property def best_builder_base_season(self): - return LegendLeagueTournamentSeasonResult(self._get_data('bestBuilderBaseSeason')) + return LegendLeagueTournamentSeasonResult( + self._get_data('bestBuilderBaseSeason') + ) @property def best_versus_season(self): - return LegendLeagueTournamentSeasonResult(self._get_data('bestVersusSeason')) + return LegendLeagueTournamentSeasonResult( + self._get_data('bestVersusSeason') + ) @property def legend_trophies(self): diff --git a/pyclasher/api/requests/abc.pyi b/pyclasher/api/requests/abc.pyi index e098fb2..6e7d8c9 100644 --- a/pyclasher/api/requests/abc.pyi +++ b/pyclasher/api/requests/abc.pyi @@ -1,9 +1,9 @@ from abc import ABC -from logging import Logger -from typing import Any, Coroutine, Iterator, Generator +from typing import Any, Iterator, Generator from ..models import Paging -from ...client import RequestMethods, Client +from ...client import Client +from ...utils import RequestMethods from ...exceptions import MISSING, Missing request_id: int = 0 diff --git a/pyclasher/api/requests/builder_base_leagues.py b/pyclasher/api/requests/builder_base_leagues.py index ed22b9d..2fb5254 100644 --- a/pyclasher/api/requests/builder_base_leagues.py +++ b/pyclasher/api/requests/builder_base_leagues.py @@ -16,7 +16,7 @@ def __init__(self, limit=None, after=None, before=None): self._main_attribute = self._len return - async def request(self): - await super().request() + async def request(self, client_id=None): + await super().request(client_id) self._main_attribute = len(self) return self diff --git a/pyclasher/api/requests/builder_base_leagues.pyi b/pyclasher/api/requests/builder_base_leagues.pyi index 1f60f46..8c438cf 100644 --- a/pyclasher/api/requests/builder_base_leagues.pyi +++ b/pyclasher/api/requests/builder_base_leagues.pyi @@ -11,9 +11,6 @@ class BuilderBaseLeaguesRequest(IterRequestModel): def __init__(self, limit: int = None, after: str = None, before: str = None): ... - async def _async_request(self) -> BuilderBaseLeaguesRequest: - ... - def items(self) -> _list_rtype: ... diff --git a/pyclasher/api/requests/clan.py b/pyclasher/api/requests/clan.py index d8d6eb6..5301c5a 100644 --- a/pyclasher/api/requests/clan.py +++ b/pyclasher/api/requests/clan.py @@ -1,5 +1,3 @@ -from asyncio import get_running_loop, run - from .abc import RequestModel from ..models import Clan, BaseClan diff --git a/pyclasher/api/requests/clan_current_war.py b/pyclasher/api/requests/clan_current_war.py index d28546d..ae73b7e 100644 --- a/pyclasher/api/requests/clan_current_war.py +++ b/pyclasher/api/requests/clan_current_war.py @@ -1,5 +1,3 @@ -from asyncio import get_running_loop, run - from .abc import RequestModel from ..models import ClanWar, BaseClan diff --git a/pyclasher/api/requests/clan_current_war.pyi b/pyclasher/api/requests/clan_current_war.pyi index 2d5e2ec..205f90e 100644 --- a/pyclasher/api/requests/clan_current_war.pyi +++ b/pyclasher/api/requests/clan_current_war.pyi @@ -1,5 +1,3 @@ -from typing import Coroutine, Any - from .abc import RequestModel from ..models import ClanWar, BaseClan diff --git a/pyclasher/api/requests/clan_currentwar_leaguegroup.py b/pyclasher/api/requests/clan_currentwar_leaguegroup.py index 2361c25..3d79a2b 100644 --- a/pyclasher/api/requests/clan_currentwar_leaguegroup.py +++ b/pyclasher/api/requests/clan_currentwar_leaguegroup.py @@ -1,5 +1,3 @@ -from asyncio import get_running_loop, run - from .abc import RequestModel from ..models import ClanWarLeagueGroup diff --git a/pyclasher/api/requests/clan_rankings.py b/pyclasher/api/requests/clan_rankings.py index e261823..121770d 100644 --- a/pyclasher/api/requests/clan_rankings.py +++ b/pyclasher/api/requests/clan_rankings.py @@ -8,7 +8,8 @@ class ClanRankingsRequest(IterRequestModel): def __init__(self, location_id, limit=None, after=None, before=None): - self.location_id = location_id if isinstance(location_id, int) else location_id.id + self.location_id = location_id if isinstance(location_id, int) \ + else location_id.id super().__init__("locations/{location_id}/rankings/clans", location_id=self.location_id, kwargs={ diff --git a/pyclasher/api/requests/clan_search.py b/pyclasher/api/requests/clan_search.py index 3c56f16..f61984a 100644 --- a/pyclasher/api/requests/clan_search.py +++ b/pyclasher/api/requests/clan_search.py @@ -65,8 +65,10 @@ def __init__( "clans", kwargs={ 'name': name, - 'warFrequency': war_frequency.value if war_frequency is not None else None, - 'locationId': location.value.id if location is not None else None, + 'warFrequency': (war_frequency.value + if war_frequency is not None else None), + 'locationId': (location.value.id + if location is not None else None), 'minMembers': min_members, 'maxMembers': max_members, 'minClanPoints': min_clan_points, @@ -75,6 +77,8 @@ def __init__( (label.value.id for label in label_ids)) if label_ids is not None else None, 'limit': limit, 'after': after, - 'before': before}) + 'before': before + } + ) self._main_attribute = self.clan_name return diff --git a/pyclasher/api/requests/league_season.py b/pyclasher/api/requests/league_season.py index d942b57..562476b 100644 --- a/pyclasher/api/requests/league_season.py +++ b/pyclasher/api/requests/league_season.py @@ -6,7 +6,12 @@ class LeagueSeasonRequest(IterRequestModel): _iter_rtype = PlayerRanking _list_rtype = PlayerRankingList - def __init__(self, league_id, season_id, limit=None, after=None, before=None): + def __init__(self, + league_id, + season_id, + limit=None, + after=None, + before=None): self.league_id = league_id self.season_id = season_id if isinstance(season_id, Season) \ else Season.from_str(season_id) diff --git a/pyclasher/api/requests/player.py b/pyclasher/api/requests/player.py index adc394a..38e471b 100644 --- a/pyclasher/api/requests/player.py +++ b/pyclasher/api/requests/player.py @@ -5,13 +5,13 @@ from .abc import RequestModel from ..models import Player, VerifyTokenRequest, VerifyTokenResponse from ...utils.request_methods import RequestMethods -from ...exceptions import ClientIsNotRunning, ApiCode +from ...exceptions import ClientIsNotRunning class PlayerRequest(RequestModel, Player): """ - Get information about a single player by player tag. Player tags can be found either in game or by - from clan member lists. + Get information about a single player by player tag. Player tags can be + found either in game or from clan member lists. """ def __init__(self, player_tag): diff --git a/pyclasher/api/requests/player.pyi b/pyclasher/api/requests/player.pyi index 74ca4a0..6df8db9 100644 --- a/pyclasher/api/requests/player.pyi +++ b/pyclasher/api/requests/player.pyi @@ -1,5 +1,3 @@ -from typing import Coroutine, Any - from .abc import RequestModel from ..models import Player, VerifyTokenResponse diff --git a/pyclasher/api/requests/player_builder_base_rankings.py b/pyclasher/api/requests/player_builder_base_rankings.py index 9955a6c..419b244 100644 --- a/pyclasher/api/requests/player_builder_base_rankings.py +++ b/pyclasher/api/requests/player_builder_base_rankings.py @@ -8,7 +8,8 @@ class PlayerBuilderBaseRankingsRequest(IterRequestModel): def __init__(self, location_id, limit=None, after=None, before=None): - self.location_id = location_id if isinstance(location_id, int) else location_id.id + self.location_id = (location_id if isinstance(location_id, int) + else location_id.id) super().__init__("locations/{location_id}" "/rankings/players-builder-base", location_id=self.location_id, diff --git a/pyclasher/api/requests/player_rankings.py b/pyclasher/api/requests/player_rankings.py index e6b2fb5..47cbcc8 100644 --- a/pyclasher/api/requests/player_rankings.py +++ b/pyclasher/api/requests/player_rankings.py @@ -8,7 +8,8 @@ class PlayerRankingsRequest(IterRequestModel): def __init__(self, location_id, limit=None, after=None, before=None): - self.location_id = location_id if isinstance(location_id, int) else location_id.id + self.location_id = (location_id if isinstance(location_id, int) + else location_id.id) super().__init__("locations/{location_id}/rankings/players", location_id=self.location_id, kwargs={ diff --git a/pyclasher/client.py b/pyclasher/client.py index 47c59d0..a28e814 100644 --- a/pyclasher/client.py +++ b/pyclasher/client.py @@ -9,7 +9,7 @@ NoneToken, MISSING, ClientAlreadyInitialised) -client_id = 0 +global_client_id = 0 class Client: @@ -30,7 +30,8 @@ def __new__(cls, *args, **kwargs): elif isinstance(kwargs['tokens'], Iterable): tokens = list(kwargs['tokens']) else: - raise InvalidType(kwargs['tokens'], (str, Iterable[str])) + raise InvalidType(kwargs['tokens'], + (str, Iterable[str])) for token in tokens: for client in Client.__instances: if client.__tokens is not None: @@ -49,7 +50,7 @@ def __init__( logger=MISSING, swagger_url=None ): - global client_id + global global_client_id if logger is None: logger = MISSING @@ -80,9 +81,9 @@ def __init__( self.__temporary_session = False self.__consumers = None self.__consume_tasks = None - self._client_id = client_id + self._client_id = global_client_id - client_id += 1 + global_client_id += 1 self._event_client = False @@ -189,7 +190,7 @@ def client_id(self): @client_id.setter def client_id(self, new_id): - global client_id + global global_client_id if isinstance(new_id, str) and new_id.isdigit(): new_id = int(new_id) diff --git a/pyclasher/client.pyi b/pyclasher/client.pyi index bff0e46..6ceb4de 100644 --- a/pyclasher/client.pyi +++ b/pyclasher/client.pyi @@ -5,7 +5,7 @@ from .exceptions import MISSING from .request_queue import PQueue -client_id: int = ... +global_client_id: int = ... class Client: diff --git a/pyclasher/exceptions.py b/pyclasher/exceptions.py index 1c99a0c..43650d0 100644 --- a/pyclasher/exceptions.py +++ b/pyclasher/exceptions.py @@ -34,12 +34,15 @@ def __init__(self, code, description, response_json=None): return def _dict_to_str(self): - return "\n".join((f" - {key}: {val}" for key, val in self.response_json.items())) + return "\n".join( + (f" - {key}: {val}" for key, val in self.response_json.items()) + ) def __str__(self): if self.response_json is None: return f"ApiException({self.code})" - return f"ApiException:\n - Code: {self.code}\n - Description: {self.description}\n{self._dict_to_str()}" + return (f"ApiException:\n - Code: {self.code}\n - Description: " + f"{self.description}\n{self._dict_to_str()}") def __repr__(self): return f"ApiException(code={self.code})" @@ -52,8 +55,9 @@ def __str__(self): class NoneToken(PyClasherException): def __str__(self): - return "The token must be passed to the client. " \ - "You can do this in the initialisation process or pass the tokens to the start function." + return ("The token must be passed to the client. " + "You can do this in the initialisation process" + " or pass the tokens to the start function.") class InvalidLoginData(PyClasherException): @@ -69,7 +73,8 @@ def __init__(self, element, allowed_types): return def __str__(self): - return f"{self.element} is of invalid type\nallowed types are {self.types}." + return (f"{self.element} is of invalid type\nallowed types are " + f"{self.types}.") class LoginNotDone(PyClasherException): @@ -106,7 +111,8 @@ def __init__(self, value, time_format): return def __str__(self): - return f"The time {self.value} does not match the format '{self.time_format}'." + return (f"The time {self.value} does not match the format " + f"'{self.time_format}'.") class ClientRunningOverwrite(PyClasherException): @@ -116,7 +122,9 @@ def __str__(self): class InvalidSeasonFormat(PyClasherException): def __str__(self): - return "The season string is not valid. It must be follow the following format: where is the year and is the month." + return ("The season string is not valid. It must be follow the " + "following format: where is the year" + " and is the month.") class RequestTimeout(PyClasherException): diff --git a/pyclasher/request_queue/request_consumer.py b/pyclasher/request_queue/request_consumer.py index 8a25d34..7e7737f 100644 --- a/pyclasher/request_queue/request_consumer.py +++ b/pyclasher/request_queue/request_consumer.py @@ -25,14 +25,16 @@ def __init__(self, queue, token, requests_per_s, request_timeout, url): async def _request(self, future, url, method, body, status, error): async with self.session.request( - method=method, url=url, data=None if body is None else dumps(body) + method=method, url=url, + data=None if body is None else dumps(body) ) as response, timeout(self.timeout): response_json = await response.json() future.set_result(response_json) status.set_result(response.status) - error.set_result(None if response.status == 200 else - ApiCodes.from_exception(response.status, response_json)) + error.set_result(None if response.status == 200 + else ApiCodes.from_exception(response.status, + response_json)) return async def consume(self): @@ -40,7 +42,11 @@ async def consume(self): future, url, method, body, status, error = await self.queue.get() async with ExecutionTimer(self.wait): - create_task(self._request(future, url, method.value, body, status, error)) + create_task( + self._request( + future, url, method.value, body, status, error + ) + ) self.queue.task_done() diff --git a/pyclasher/request_queue/request_queue.py b/pyclasher/request_queue/request_queue.py index c90fd88..e940541 100644 --- a/pyclasher/request_queue/request_queue.py +++ b/pyclasher/request_queue/request_queue.py @@ -2,5 +2,13 @@ class PQueue(Queue): - async def put(self, future, request_url, request_method, body, status, error): - return await super().put((future, request_url, request_method, body, status, error)) + async def put(self, + future, + request_url, + request_method, + body, + status, + error): + return await super().put( + (future, request_url, request_method, body, status, error) + ) diff --git a/pyclasher/utils/__init__.py b/pyclasher/utils/__init__.py index 44b34f0..98ee5d7 100644 --- a/pyclasher/utils/__init__.py +++ b/pyclasher/utils/__init__.py @@ -1 +1,3 @@ from .exectimer import ExecutionTimer +from .login import Login +from .request_methods import RequestMethods diff --git a/pyclasher/utils/login.py b/pyclasher/utils/login.py index 9a441d1..bb24008 100644 --- a/pyclasher/utils/login.py +++ b/pyclasher/utils/login.py @@ -3,7 +3,7 @@ from aiohttp import request from ..api.models.login import LoginModel -from ..exceptions import Missing, MISSING, LoginNotDone, InvalidLoginData +from ..exceptions import MISSING, LoginNotDone, InvalidLoginData class Login(LoginModel): @@ -20,7 +20,7 @@ def __init__(self, email, password): return - def _get_data(self, item: str) -> None | Missing | dict | list | int | str | float | bool: + def _get_data(self, item): if self._data is None: return None if self._data is MISSING: diff --git a/pyclasher/utils/login.pyi b/pyclasher/utils/login.pyi index f2cc60c..bdadfae 100644 --- a/pyclasher/utils/login.pyi +++ b/pyclasher/utils/login.pyi @@ -1,10 +1,7 @@ -from asyncio import get_running_loop, run -from typing import Coroutine - -from aiohttp import request +from typing import Coroutine, Any from ..api.models.login import LoginModel -from ..exceptions import Missing, MISSING, LoginNotDone, InvalidLoginData +from ..exceptions import Missing class Login(LoginModel): @@ -25,6 +22,11 @@ class Login(LoginModel): self.__password = password ... + def _get_data( + self, item: str + ) -> None | Missing | dict | list | int | str | float | bool: + ... + def login(self) -> Login | Coroutine[Any, Any, Login]: """ method to execute the login process diff --git a/setup.py b/setup.py index b76ae7c..0c8ea6d 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,8 @@ name='pyclasher', version=pyclasher.__version__, author='201st-Luka', - description='pyclasher - an object-oriented wrapper client for Python that provides easy access to the requested data', + description='pyclasher - an object-oriented wrapper client for Python ' + 'that provides easy access to the requested data', long_description=readme, long_description_content_type='text/markdown', packages=packages, diff --git a/tests/requests/conftest.py b/tests/requests/conftest.py index b341ce1..365327d 100644 --- a/tests/requests/conftest.py +++ b/tests/requests/conftest.py @@ -22,7 +22,8 @@ def event_loop(): @pytest_asyncio.fixture(scope="package") async def pyclasher_client(event_loop): print("Setting PyClasherClient ...") - client = await Client.from_login(CLASH_OF_CLANS_LOGIN_EMAIL, CLASH_OF_CLANS_LOGIN_PASSWORD) + client = await Client.from_login(CLASH_OF_CLANS_LOGIN_EMAIL, + CLASH_OF_CLANS_LOGIN_PASSWORD) await client.start() yield client diff --git a/tests/requests/test_player.py b/tests/requests/test_player.py index bc2f2f7..8c2aa15 100644 --- a/tests/requests/test_player.py +++ b/tests/requests/test_player.py @@ -4,7 +4,7 @@ from pyclasher.api.models import ( ClanRole, PlayerHouse, PlayerClan, PlayerAchievementProgressList, BuilderBaseLeague, PlayerItemLevelList, LabelList, League, - PlayerLegendStatistics,WarPreference + PlayerLegendStatistics, WarPreference ) from ..constants import TEST_PLAYER_TAG From 94d76b0dfcd13282c4c627ff5a8be9146e38ac72 Mon Sep 17 00:00:00 2001 From: 201st-Luka Date: Thu, 24 Aug 2023 09:50:57 +0200 Subject: [PATCH 4/4] fix: merging broke client id setting --- pyclasher/client.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyclasher/client.py b/pyclasher/client.py index 97ba456..deaaf20 100644 --- a/pyclasher/client.py +++ b/pyclasher/client.py @@ -207,6 +207,8 @@ def client_id(self, new_id): if " " in new_id: raise PyClasherException("`new_id` must not contain spaces") + self._client_id = new_id + return @classmethod