deadcode 2.2.1__tar.gz → 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {deadcode-2.2.1 → deadcode-2.3.0}/PKG-INFO +70 -24
- {deadcode-2.2.1 → deadcode-2.3.0}/README.md +69 -23
- deadcode-2.3.0/black/action/main.py +176 -0
- deadcode-2.3.0/black/docs/conf.py +218 -0
- deadcode-2.3.0/black/gallery/gallery.py +294 -0
- deadcode-2.3.0/black/profiling/dict_big.py +8001 -0
- deadcode-2.3.0/black/profiling/dict_huge.py +41440 -0
- deadcode-2.3.0/black/profiling/list_big.py +4000 -0
- deadcode-2.3.0/black/profiling/list_huge.py +22431 -0
- deadcode-2.3.0/black/profiling/mix_big.py +1002 -0
- deadcode-2.3.0/black/profiling/mix_huge.py +7692 -0
- deadcode-2.3.0/black/profiling/mix_small.py +102 -0
- deadcode-2.3.0/black/scripts/check_pre_commit_rev_in_example.py +54 -0
- deadcode-2.3.0/black/scripts/check_version_in_basics_example.py +48 -0
- deadcode-2.3.0/black/scripts/diff_shades_gha_helper.py +236 -0
- deadcode-2.3.0/black/scripts/fuzz.py +92 -0
- deadcode-2.3.0/black/scripts/generate_schema.py +74 -0
- deadcode-2.3.0/black/scripts/make_width_table.py +66 -0
- deadcode-2.3.0/black/scripts/migrate-black.py +96 -0
- deadcode-2.3.0/black/scripts/release.py +245 -0
- deadcode-2.3.0/black/scripts/release_tests.py +69 -0
- deadcode-2.3.0/black/src/black/__init__.py +1605 -0
- deadcode-2.3.0/black/src/black/__main__.py +3 -0
- deadcode-2.3.0/black/src/black/_width_table.py +478 -0
- deadcode-2.3.0/black/src/black/brackets.py +382 -0
- deadcode-2.3.0/black/src/black/cache.py +150 -0
- deadcode-2.3.0/black/src/black/comments.py +415 -0
- deadcode-2.3.0/black/src/black/concurrency.py +190 -0
- deadcode-2.3.0/black/src/black/const.py +4 -0
- deadcode-2.3.0/black/src/black/debug.py +54 -0
- deadcode-2.3.0/black/src/black/files.py +433 -0
- deadcode-2.3.0/black/src/black/handle_ipynb_magics.py +452 -0
- deadcode-2.3.0/black/src/black/linegen.py +1745 -0
- deadcode-2.3.0/black/src/black/lines.py +1073 -0
- deadcode-2.3.0/black/src/black/mode.py +265 -0
- deadcode-2.3.0/black/src/black/nodes.py +1007 -0
- deadcode-2.3.0/black/src/black/numerics.py +61 -0
- deadcode-2.3.0/black/src/black/output.py +122 -0
- deadcode-2.3.0/black/src/black/parsing.py +244 -0
- deadcode-2.3.0/black/src/black/ranges.py +521 -0
- deadcode-2.3.0/black/src/black/report.py +107 -0
- deadcode-2.3.0/black/src/black/rusty.py +28 -0
- deadcode-2.3.0/black/src/black/schema.py +20 -0
- deadcode-2.3.0/black/src/black/strings.py +325 -0
- deadcode-2.3.0/black/src/black/trans.py +2534 -0
- deadcode-2.3.0/black/src/blackd/__init__.py +259 -0
- deadcode-2.3.0/black/src/blackd/__main__.py +3 -0
- deadcode-2.3.0/black/src/blackd/middlewares.py +45 -0
- deadcode-2.3.0/black/src/blib2to3/__init__.py +1 -0
- deadcode-2.3.0/black/src/blib2to3/pgen2/__init__.py +4 -0
- deadcode-2.3.0/black/src/blib2to3/pgen2/conv.py +256 -0
- deadcode-2.3.0/black/src/blib2to3/pgen2/driver.py +316 -0
- deadcode-2.3.0/black/src/blib2to3/pgen2/grammar.py +227 -0
- deadcode-2.3.0/black/src/blib2to3/pgen2/literals.py +66 -0
- deadcode-2.3.0/black/src/blib2to3/pgen2/parse.py +411 -0
- deadcode-2.3.0/black/src/blib2to3/pgen2/pgen.py +428 -0
- deadcode-2.3.0/black/src/blib2to3/pgen2/token.py +88 -0
- deadcode-2.3.0/black/src/blib2to3/pgen2/tokenize.py +698 -0
- deadcode-2.3.0/black/src/blib2to3/pygram.py +200 -0
- deadcode-2.3.0/black/src/blib2to3/pytree.py +986 -0
- deadcode-2.3.0/black/tests/conftest.py +28 -0
- deadcode-2.3.0/black/tests/data/cases/allow_empty_first_line.py +166 -0
- deadcode-2.3.0/black/tests/data/cases/async_stmts.py +27 -0
- deadcode-2.3.0/black/tests/data/cases/attribute_access_on_number_literals.py +47 -0
- deadcode-2.3.0/black/tests/data/cases/beginning_backslash.py +12 -0
- deadcode-2.3.0/black/tests/data/cases/bracketmatch.py +15 -0
- deadcode-2.3.0/black/tests/data/cases/bytes_docstring.py +34 -0
- deadcode-2.3.0/black/tests/data/cases/class_blank_parentheses.py +59 -0
- deadcode-2.3.0/black/tests/data/cases/class_methods_new_line.py +270 -0
- deadcode-2.3.0/black/tests/data/cases/collections.py +174 -0
- deadcode-2.3.0/black/tests/data/cases/comment_after_escaped_newline.py +18 -0
- deadcode-2.3.0/black/tests/data/cases/comment_type_hint.py +3 -0
- deadcode-2.3.0/black/tests/data/cases/comments.py +96 -0
- deadcode-2.3.0/black/tests/data/cases/comments2.py +344 -0
- deadcode-2.3.0/black/tests/data/cases/comments3.py +48 -0
- deadcode-2.3.0/black/tests/data/cases/comments4.py +94 -0
- deadcode-2.3.0/black/tests/data/cases/comments5.py +70 -0
- deadcode-2.3.0/black/tests/data/cases/comments6.py +118 -0
- deadcode-2.3.0/black/tests/data/cases/comments8.py +15 -0
- deadcode-2.3.0/black/tests/data/cases/comments9.py +305 -0
- deadcode-2.3.0/black/tests/data/cases/comments_in_blocks.py +111 -0
- deadcode-2.3.0/black/tests/data/cases/comments_in_double_parens.py +113 -0
- deadcode-2.3.0/black/tests/data/cases/comments_non_breaking_space.py +44 -0
- deadcode-2.3.0/black/tests/data/cases/composition.py +181 -0
- deadcode-2.3.0/black/tests/data/cases/composition_no_trailing_comma.py +367 -0
- deadcode-2.3.0/black/tests/data/cases/conditional_expression.py +204 -0
- deadcode-2.3.0/black/tests/data/cases/context_managers_38.py +55 -0
- deadcode-2.3.0/black/tests/data/cases/context_managers_39.py +175 -0
- deadcode-2.3.0/black/tests/data/cases/context_managers_autodetect_310.py +36 -0
- deadcode-2.3.0/black/tests/data/cases/context_managers_autodetect_311.py +38 -0
- deadcode-2.3.0/black/tests/data/cases/context_managers_autodetect_38.py +46 -0
- deadcode-2.3.0/black/tests/data/cases/context_managers_autodetect_39.py +35 -0
- deadcode-2.3.0/black/tests/data/cases/docstring.py +457 -0
- deadcode-2.3.0/black/tests/data/cases/docstring_newline_preview.py +4 -0
- deadcode-2.3.0/black/tests/data/cases/docstring_no_extra_empty_line_before_eof.py +4 -0
- deadcode-2.3.0/black/tests/data/cases/docstring_no_string_normalization.py +250 -0
- deadcode-2.3.0/black/tests/data/cases/docstring_preview.py +104 -0
- deadcode-2.3.0/black/tests/data/cases/dummy_implementations.py +144 -0
- deadcode-2.3.0/black/tests/data/cases/empty_lines.py +187 -0
- deadcode-2.3.0/black/tests/data/cases/expression.py +630 -0
- deadcode-2.3.0/black/tests/data/cases/f_docstring.py +20 -0
- deadcode-2.3.0/black/tests/data/cases/fmtonoff.py +409 -0
- deadcode-2.3.0/black/tests/data/cases/fmtonoff2.py +40 -0
- deadcode-2.3.0/black/tests/data/cases/fmtonoff3.py +35 -0
- deadcode-2.3.0/black/tests/data/cases/fmtonoff4.py +36 -0
- deadcode-2.3.0/black/tests/data/cases/fmtonoff5.py +175 -0
- deadcode-2.3.0/black/tests/data/cases/fmtpass_imports.py +19 -0
- deadcode-2.3.0/black/tests/data/cases/fmtskip.py +3 -0
- deadcode-2.3.0/black/tests/data/cases/fmtskip2.py +20 -0
- deadcode-2.3.0/black/tests/data/cases/fmtskip3.py +20 -0
- deadcode-2.3.0/black/tests/data/cases/fmtskip4.py +13 -0
- deadcode-2.3.0/black/tests/data/cases/fmtskip5.py +22 -0
- deadcode-2.3.0/black/tests/data/cases/fmtskip6.py +13 -0
- deadcode-2.3.0/black/tests/data/cases/fmtskip7.py +11 -0
- deadcode-2.3.0/black/tests/data/cases/fmtskip8.py +62 -0
- deadcode-2.3.0/black/tests/data/cases/fmtskip9.py +9 -0
- deadcode-2.3.0/black/tests/data/cases/form_feeds.py +226 -0
- deadcode-2.3.0/black/tests/data/cases/fstring.py +25 -0
- deadcode-2.3.0/black/tests/data/cases/funcdef_return_type_trailing_comma.py +301 -0
- deadcode-2.3.0/black/tests/data/cases/function.py +244 -0
- deadcode-2.3.0/black/tests/data/cases/function2.py +121 -0
- deadcode-2.3.0/black/tests/data/cases/function_trailing_comma.py +178 -0
- deadcode-2.3.0/black/tests/data/cases/ignore_pyi.py +42 -0
- deadcode-2.3.0/black/tests/data/cases/import_spacing.py +118 -0
- deadcode-2.3.0/black/tests/data/cases/is_simple_lookup_for_doublestar_expression.py +14 -0
- deadcode-2.3.0/black/tests/data/cases/keep_newline_after_match.py +41 -0
- deadcode-2.3.0/black/tests/data/cases/line_ranges_basic.py +107 -0
- deadcode-2.3.0/black/tests/data/cases/line_ranges_diff_edge_case.py +28 -0
- deadcode-2.3.0/black/tests/data/cases/line_ranges_exceeding_end.py +36 -0
- deadcode-2.3.0/black/tests/data/cases/line_ranges_fmt_off.py +49 -0
- deadcode-2.3.0/black/tests/data/cases/line_ranges_fmt_off_decorator.py +47 -0
- deadcode-2.3.0/black/tests/data/cases/line_ranges_fmt_off_overlap.py +37 -0
- deadcode-2.3.0/black/tests/data/cases/line_ranges_imports.py +9 -0
- deadcode-2.3.0/black/tests/data/cases/line_ranges_indentation.py +27 -0
- deadcode-2.3.0/black/tests/data/cases/line_ranges_outside_source.py +7 -0
- deadcode-2.3.0/black/tests/data/cases/line_ranges_two_passes.py +27 -0
- deadcode-2.3.0/black/tests/data/cases/line_ranges_unwrapping.py +25 -0
- deadcode-2.3.0/black/tests/data/cases/linelength6.py +6 -0
- deadcode-2.3.0/black/tests/data/cases/long_strings_flag_disabled.py +296 -0
- deadcode-2.3.0/black/tests/data/cases/module_docstring_1.py +25 -0
- deadcode-2.3.0/black/tests/data/cases/module_docstring_2.py +70 -0
- deadcode-2.3.0/black/tests/data/cases/module_docstring_3.py +7 -0
- deadcode-2.3.0/black/tests/data/cases/module_docstring_4.py +8 -0
- deadcode-2.3.0/black/tests/data/cases/module_docstring_followed_by_class.py +10 -0
- deadcode-2.3.0/black/tests/data/cases/module_docstring_followed_by_function.py +10 -0
- deadcode-2.3.0/black/tests/data/cases/multiline_consecutive_open_parentheses_ignore.py +41 -0
- deadcode-2.3.0/black/tests/data/cases/nested_stub.py +69 -0
- deadcode-2.3.0/black/tests/data/cases/no_blank_line_before_docstring.py +66 -0
- deadcode-2.3.0/black/tests/data/cases/numeric_literals.py +39 -0
- deadcode-2.3.0/black/tests/data/cases/numeric_literals_skip_underscores.py +19 -0
- deadcode-2.3.0/black/tests/data/cases/one_element_subscript.py +36 -0
- deadcode-2.3.0/black/tests/data/cases/parenthesized_context_managers.py +46 -0
- deadcode-2.3.0/black/tests/data/cases/pattern_matching_complex.py +155 -0
- deadcode-2.3.0/black/tests/data/cases/pattern_matching_extras.py +102 -0
- deadcode-2.3.0/black/tests/data/cases/pattern_matching_generic.py +108 -0
- deadcode-2.3.0/black/tests/data/cases/pattern_matching_long.py +34 -0
- deadcode-2.3.0/black/tests/data/cases/pattern_matching_simple.py +93 -0
- deadcode-2.3.0/black/tests/data/cases/pattern_matching_style.py +92 -0
- deadcode-2.3.0/black/tests/data/cases/pattern_matching_trailing_comma.py +39 -0
- deadcode-2.3.0/black/tests/data/cases/pattern_matching_with_if_stmt.py +72 -0
- deadcode-2.3.0/black/tests/data/cases/pep604_union_types_line_breaks.py +188 -0
- deadcode-2.3.0/black/tests/data/cases/pep_570.py +45 -0
- deadcode-2.3.0/black/tests/data/cases/pep_572.py +48 -0
- deadcode-2.3.0/black/tests/data/cases/pep_572_do_not_remove_parens.py +26 -0
- deadcode-2.3.0/black/tests/data/cases/pep_572_py310.py +16 -0
- deadcode-2.3.0/black/tests/data/cases/pep_572_py39.py +8 -0
- deadcode-2.3.0/black/tests/data/cases/pep_572_remove_parens.py +142 -0
- deadcode-2.3.0/black/tests/data/cases/pep_572_slices.py +6 -0
- deadcode-2.3.0/black/tests/data/cases/pep_604.py +25 -0
- deadcode-2.3.0/black/tests/data/cases/pep_646.py +195 -0
- deadcode-2.3.0/black/tests/data/cases/pep_654.py +54 -0
- deadcode-2.3.0/black/tests/data/cases/pep_654_style.py +112 -0
- deadcode-2.3.0/black/tests/data/cases/percent_precedence.py +41 -0
- deadcode-2.3.0/black/tests/data/cases/power_op_newline.py +11 -0
- deadcode-2.3.0/black/tests/data/cases/power_op_spacing.py +149 -0
- deadcode-2.3.0/black/tests/data/cases/power_op_spacing_long.py +96 -0
- deadcode-2.3.0/black/tests/data/cases/prefer_rhs_split.py +106 -0
- deadcode-2.3.0/black/tests/data/cases/prefer_rhs_split_reformatted.py +38 -0
- deadcode-2.3.0/black/tests/data/cases/preview_cantfit.py +94 -0
- deadcode-2.3.0/black/tests/data/cases/preview_cantfit_string.py +18 -0
- deadcode-2.3.0/black/tests/data/cases/preview_comments7.py +309 -0
- deadcode-2.3.0/black/tests/data/cases/preview_format_unicode_escape_seq.py +34 -0
- deadcode-2.3.0/black/tests/data/cases/preview_hug_parens_with_braces_and_square_brackets.py +347 -0
- deadcode-2.3.0/black/tests/data/cases/preview_hug_parens_with_braces_and_square_brackets_no_ll1.py +106 -0
- deadcode-2.3.0/black/tests/data/cases/preview_long_dict_values.py +129 -0
- deadcode-2.3.0/black/tests/data/cases/preview_long_strings.py +928 -0
- deadcode-2.3.0/black/tests/data/cases/preview_long_strings__east_asian_width.py +26 -0
- deadcode-2.3.0/black/tests/data/cases/preview_long_strings__edge_case.py +141 -0
- deadcode-2.3.0/black/tests/data/cases/preview_long_strings__regression.py +1247 -0
- deadcode-2.3.0/black/tests/data/cases/preview_long_strings__type_annotations.py +60 -0
- deadcode-2.3.0/black/tests/data/cases/preview_multiline_strings.py +401 -0
- deadcode-2.3.0/black/tests/data/cases/preview_return_annotation_brackets_string.py +24 -0
- deadcode-2.3.0/black/tests/data/cases/py310_pep572.py +13 -0
- deadcode-2.3.0/black/tests/data/cases/python37.py +62 -0
- deadcode-2.3.0/black/tests/data/cases/python38.py +42 -0
- deadcode-2.3.0/black/tests/data/cases/python39.py +30 -0
- deadcode-2.3.0/black/tests/data/cases/raw_docstring.py +32 -0
- deadcode-2.3.0/black/tests/data/cases/raw_docstring_no_string_normalization.py +11 -0
- deadcode-2.3.0/black/tests/data/cases/remove_await_parens.py +195 -0
- deadcode-2.3.0/black/tests/data/cases/remove_except_parens.py +79 -0
- deadcode-2.3.0/black/tests/data/cases/remove_for_brackets.py +48 -0
- deadcode-2.3.0/black/tests/data/cases/remove_newline_after_code_block_open.py +212 -0
- deadcode-2.3.0/black/tests/data/cases/remove_parens.py +142 -0
- deadcode-2.3.0/black/tests/data/cases/remove_redundant_parens_in_case_guard.py +114 -0
- deadcode-2.3.0/black/tests/data/cases/remove_with_brackets.py +120 -0
- deadcode-2.3.0/black/tests/data/cases/return_annotation_brackets.py +219 -0
- deadcode-2.3.0/black/tests/data/cases/single_line_format_skip_with_multiple_comments.py +19 -0
- deadcode-2.3.0/black/tests/data/cases/skip_magic_trailing_comma.py +75 -0
- deadcode-2.3.0/black/tests/data/cases/slices.py +31 -0
- deadcode-2.3.0/black/tests/data/cases/split_delimiter_comments.py +51 -0
- deadcode-2.3.0/black/tests/data/cases/starred_for_target.py +28 -0
- deadcode-2.3.0/black/tests/data/cases/string_prefixes.py +45 -0
- deadcode-2.3.0/black/tests/data/cases/stub.py +152 -0
- deadcode-2.3.0/black/tests/data/cases/torture.py +91 -0
- deadcode-2.3.0/black/tests/data/cases/trailing_comma.py +55 -0
- deadcode-2.3.0/black/tests/data/cases/trailing_comma_optional_parens1.py +63 -0
- deadcode-2.3.0/black/tests/data/cases/trailing_comma_optional_parens2.py +12 -0
- deadcode-2.3.0/black/tests/data/cases/trailing_comma_optional_parens3.py +21 -0
- deadcode-2.3.0/black/tests/data/cases/trailing_commas_in_leading_parts.py +88 -0
- deadcode-2.3.0/black/tests/data/cases/tricky_unicode_symbols.py +9 -0
- deadcode-2.3.0/black/tests/data/cases/tupleassign.py +23 -0
- deadcode-2.3.0/black/tests/data/cases/type_aliases.py +30 -0
- deadcode-2.3.0/black/tests/data/cases/type_comment_syntax_error.py +11 -0
- deadcode-2.3.0/black/tests/data/cases/type_params.py +58 -0
- deadcode-2.3.0/black/tests/data/cases/typed_params_trailing_comma.py +24 -0
- deadcode-2.3.0/black/tests/data/cases/walrus_in_dict.py +9 -0
- deadcode-2.3.0/black/tests/data/cases/whitespace.py +6 -0
- deadcode-2.3.0/black/tests/data/ignore_subfolders_gitignore_tests/subdir/subdir/c.py +0 -0
- deadcode-2.3.0/black/tests/data/include_exclude_tests/b/.definitely_exclude/a.py +0 -0
- deadcode-2.3.0/black/tests/data/include_exclude_tests/b/dont_exclude/a.py +0 -0
- deadcode-2.3.0/black/tests/data/include_exclude_tests/b/exclude/a.py +0 -0
- deadcode-2.3.0/black/tests/data/invalid_gitignore_tests/a.py +0 -0
- deadcode-2.3.0/black/tests/data/invalid_nested_gitignore_tests/a/a.py +0 -0
- deadcode-2.3.0/black/tests/data/invalid_nested_gitignore_tests/a.py +0 -0
- deadcode-2.3.0/black/tests/data/line_ranges_formatted/basic.py +50 -0
- deadcode-2.3.0/black/tests/data/line_ranges_formatted/pattern_matching.py +25 -0
- deadcode-2.3.0/black/tests/data/miscellaneous/async_as_identifier.py +49 -0
- deadcode-2.3.0/black/tests/data/miscellaneous/blackd_diff.py +6 -0
- deadcode-2.3.0/black/tests/data/miscellaneous/debug_visitor.py +32 -0
- deadcode-2.3.0/black/tests/data/miscellaneous/decorators.py +182 -0
- deadcode-2.3.0/black/tests/data/miscellaneous/force_py36.py +16 -0
- deadcode-2.3.0/black/tests/data/miscellaneous/force_pyi.py +66 -0
- deadcode-2.3.0/black/tests/data/miscellaneous/invalid_header.py +2 -0
- deadcode-2.3.0/black/tests/data/miscellaneous/missing_final_newline.py +3 -0
- deadcode-2.3.0/black/tests/data/miscellaneous/pattern_matching_invalid.py +18 -0
- deadcode-2.3.0/black/tests/data/miscellaneous/python2_detection.py +90 -0
- deadcode-2.3.0/black/tests/data/miscellaneous/string_quotes.py +114 -0
- deadcode-2.3.0/black/tests/data/nested_gitignore_tests/root/a.py +1 -0
- deadcode-2.3.0/black/tests/data/nested_gitignore_tests/root/b.py +1 -0
- deadcode-2.3.0/black/tests/data/nested_gitignore_tests/root/c.py +1 -0
- deadcode-2.3.0/black/tests/data/nested_gitignore_tests/root/child/a.py +1 -0
- deadcode-2.3.0/black/tests/data/nested_gitignore_tests/root/child/b.py +1 -0
- deadcode-2.3.0/black/tests/data/nested_gitignore_tests/root/child/c.py +1 -0
- deadcode-2.3.0/black/tests/data/nested_gitignore_tests/x.py +0 -0
- deadcode-2.3.0/black/tests/optional.py +132 -0
- deadcode-2.3.0/black/tests/test_black.py +2980 -0
- deadcode-2.3.0/black/tests/test_blackd.py +248 -0
- deadcode-2.3.0/black/tests/test_docs.py +74 -0
- deadcode-2.3.0/black/tests/test_format.py +90 -0
- deadcode-2.3.0/black/tests/test_ipynb.py +517 -0
- deadcode-2.3.0/black/tests/test_no_ipynb.py +36 -0
- deadcode-2.3.0/black/tests/test_ranges.py +249 -0
- deadcode-2.3.0/black/tests/test_schema.py +17 -0
- deadcode-2.3.0/black/tests/test_trans.py +51 -0
- deadcode-2.3.0/black/tests/util.py +354 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/call_arg_map_to_parameters_poc.py +3 -3
- deadcode-2.3.0/deadcode/__init__.py +0 -0
- deadcode-2.3.0/deadcode/actions/__init__.py +0 -0
- deadcode-2.2.1/deadcode/actions/fix_unused_code.py → deadcode-2.3.0/deadcode/actions/fix_or_show_unused_code.py +25 -4
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/actions/parse_arguments.py +24 -6
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/cli.py +5 -4
- deadcode-2.3.0/deadcode/constants.py +49 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/data_types.py +1 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/base.py +2 -2
- deadcode-2.3.0/deadcode/tests/cli_args/test_count.py +0 -0
- deadcode-2.3.0/deadcode/tests/cli_args/test_dry.py +318 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/cli_args/test_fix.py +5 -5
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/cli_args/test_ignore_bodies_if_inherits_from.py +3 -3
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/cli_args/test_ignore_definitions.py +1 -1
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/cli_args/test_ignore_definitions_if_inherits_from.py +4 -4
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/cli_args/test_ignore_names.py +3 -3
- deadcode-2.3.0/deadcode/tests/cli_args/test_ignore_names_in_files.py +0 -0
- deadcode-2.3.0/deadcode/tests/cli_args/test_no_color.py +0 -0
- deadcode-2.3.0/deadcode/tests/cli_args/test_parsing.py +113 -0
- deadcode-2.3.0/deadcode/tests/cli_args/test_quiet.py +0 -0
- deadcode-2.3.0/deadcode/tests/cli_args/test_verbose.py +0 -0
- deadcode-2.3.0/deadcode/tests/code_item/test_code_item.py +16 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/fix/test_assign.py +2 -2
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/fix/test_class_def.py +4 -4
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/fix/test_empty_files.py +2 -2
- deadcode-2.3.0/deadcode/tests/nested_scope/test_nested_scope.py +180 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/noqa/test_noqa_comments.py +28 -28
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/test_deadcode.py +11 -11
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/test_imports.py +3 -3
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/test_output.py +6 -6
- deadcode-2.3.0/deadcode/tests/utils/test_add_colors_to_diff.py +38 -0
- deadcode-2.3.0/deadcode/utils/__init__.py +0 -0
- deadcode-2.3.0/deadcode/utils/add_colors_to_diff.py +10 -0
- deadcode-2.3.0/deadcode/utils/nested_scopes.py +83 -0
- deadcode-2.3.0/deadcode/visitor/__init__.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/visitor/code_item.py +12 -11
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/visitor/dead_code_visitor.py +84 -156
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/visitor/ignore.py +13 -13
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/visitor/noqa.py +27 -14
- {deadcode-2.2.1 → deadcode-2.3.0}/pyproject.toml +6 -3
- deadcode-2.2.1/deadcode/constants.py +0 -49
- deadcode-2.2.1/deadcode/tests/cli_args/test_parsing.py +0 -66
- {deadcode-2.2.1 → deadcode-2.3.0}/.gitignore +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/LICENSE +0 -0
- {deadcode-2.2.1/deadcode → deadcode-2.3.0/black/scripts}/__init__.py +0 -0
- {deadcode-2.2.1/deadcode/actions → deadcode-2.3.0/black/src/black/resources}/__init__.py +0 -0
- {deadcode-2.2.1/deadcode/utils → deadcode-2.3.0/black/tests}/__init__.py +0 -0
- /deadcode-2.2.1/deadcode/tests/cli_args/test_count.py → /deadcode-2.3.0/black/tests/data/gitignore_used_on_multiple_sources/dir1/a.py +0 -0
- /deadcode-2.2.1/deadcode/tests/cli_args/test_ignore_names_in_files.py → /deadcode-2.3.0/black/tests/data/gitignore_used_on_multiple_sources/dir1/b.py +0 -0
- /deadcode-2.2.1/deadcode/tests/cli_args/test_no_color.py → /deadcode-2.3.0/black/tests/data/gitignore_used_on_multiple_sources/dir2/a.py +0 -0
- /deadcode-2.2.1/deadcode/tests/cli_args/test_quiet.py → /deadcode-2.3.0/black/tests/data/gitignore_used_on_multiple_sources/dir2/b.py +0 -0
- /deadcode-2.2.1/deadcode/tests/cli_args/test_verbose.py → /deadcode-2.3.0/black/tests/data/ignore_subfolders_gitignore_tests/a.py +0 -0
- /deadcode-2.2.1/deadcode/visitor/__init__.py → /deadcode-2.3.0/black/tests/data/ignore_subfolders_gitignore_tests/subdir/b.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/actions/find_python_filenames.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/actions/find_unused_names.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/actions/get_unused_names_error_message.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/actions/merge_overlaping_file_parts.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/actions/parse_abstract_syntax_tree.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/actions/remove_file_parts_from_content.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/actions/test_find_python_filenames.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/actions/test_merge_overlaping_file_parts.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/cli_args/test_exclude.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/files/classes.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/files/functions.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/files/subdir/another_subdir/__init__.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/files/subdir/one_more_file.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/files/variables.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/fix/test_method_def.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/fix/test_scope.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/fix/test_unreachable_code.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/test_accurate_usage_detection.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/test_line_number_detection.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/test_variable_parsing_from_ast_dump.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/tests/utils/test_fix_indent.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/utils/fix_indent.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/utils/flatten_lists.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/utils/print_ast.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/visitor/lines.py +0 -0
- {deadcode-2.2.1 → deadcode-2.3.0}/deadcode/visitor/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: deadcode
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Find and remove dead code.
|
|
5
5
|
Project-URL: Homepage, https://github.com/albertas/deadcode
|
|
6
6
|
Project-URL: Documentation, https://deadcode.readthedocs.io/
|
|
@@ -19,10 +19,16 @@ Requires-Python: >=3.8
|
|
|
19
19
|
Requires-Dist: tomli==2.0.1
|
|
20
20
|
Description-Content-Type: text/markdown
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
[](https://deadcode.readthedocs.io/en/stable/)
|
|
23
|
+
|
|
24
|
+
<h2 align="center">Find and Fix Unused Python Code</h2>
|
|
25
|
+
|
|
26
|
+
<p align="center">
|
|
27
|
+
<a href="https://github.com/albertas/deadcode/blob/main/LICENSE"><img alt="License: AGPLv3" src="https://raw.githubusercontent.com/albertas/deadcode/main/docs/_static/AGPLv3-license.svg"></a>
|
|
28
|
+
<a href="https://pypi.org/project/deadcode/"><img alt="PyPI" src="https://img.shields.io/pypi/v/deadcode"></a>
|
|
29
|
+
<a href="https://pepy.tech/project/deadcode"><img alt="Downloads" src="https://static.pepy.tech/badge/deadcode"></a>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
26
32
|
|
|
27
33
|
## Installation
|
|
28
34
|
```shell
|
|
@@ -30,11 +36,27 @@ pip install deadcode
|
|
|
30
36
|
```
|
|
31
37
|
|
|
32
38
|
## Usage
|
|
39
|
+
To see unused code findings:
|
|
33
40
|
```shell
|
|
34
41
|
deadcode .
|
|
35
42
|
```
|
|
36
43
|
|
|
37
|
-
|
|
44
|
+
To see suggested fixes for all files:
|
|
45
|
+
```shell
|
|
46
|
+
deadcode . --fix --dry
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
To see suggested fixes for only `foo.py` file:
|
|
50
|
+
```shell
|
|
51
|
+
deadcode . --fix --dry foo.py
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
To fix:
|
|
55
|
+
```shell
|
|
56
|
+
deadcode . --fix
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Tune out some of the false positives, e.g.:
|
|
38
60
|
```
|
|
39
61
|
deadcode . --exclude=venv,tests --ignore-names=BaseTestCase,*Mixin --ignore-names-in-files=migrations
|
|
40
62
|
```
|
|
@@ -52,6 +74,7 @@ ignore-names-in-files = ["migrations"]
|
|
|
52
74
|
| Option | Type | Meaning |
|
|
53
75
|
|-------------------------------------------|------|----------------------------------------------------------------------|
|
|
54
76
|
|`--fix` | - | Automatically remove detected unused code expressions from the code base. |
|
|
77
|
+
|`--dry` | - or list | Show changes which would be made in files. Shows changes for provided filenames or shows all changes if no filename is specified. |
|
|
55
78
|
|`--exclude` | list | Filenames (or path expressions), which will be completely skipped without being analysed. |
|
|
56
79
|
|`--ignore-names` | list | Removes provided list of names from the output. Regexp expressions to match multiple names can also be provided, e.g. `*Mixin` will match all classes ending with `Mixin`. |
|
|
57
80
|
|`--ignore-names-in-files` | list | Ignores unused names in files, which filenames match provided path expressions. |
|
|
@@ -77,27 +100,26 @@ definition - whole class or function definition expression including its name an
|
|
|
77
100
|
## Rules
|
|
78
101
|
| Code | Name | Message |
|
|
79
102
|
|--------|--------------------|----------------|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
93
|
-
`*` - are not yet implemented rules.
|
|
103
|
+
| DC01 | unused-variable | Variable `{name}` is never used
|
|
104
|
+
| DC02 | unused-function | Function `{name}` is never used
|
|
105
|
+
| DC03 | unused-class | Class `{name}` is never used
|
|
106
|
+
| DC04 | unused-method | Method `{name}` is never used
|
|
107
|
+
| DC05 | unused-attribute | Attribute `{name}` is never used
|
|
108
|
+
| DC06 | unused-name | Name `{name}` is never used
|
|
109
|
+
| DC07 | unused-import | Import `{name}` is never used
|
|
110
|
+
| DC08 | unused-property | Property `{name}` is never used
|
|
111
|
+
| DC09 | unreachable-if-block | Unreachable conditional statement block
|
|
112
|
+
| DC11 | empty-file | Empty Python file
|
|
113
|
+
| DC12 | commented-out-code | Commented out code
|
|
114
|
+
| DC13 | unreachable-code | Code after terminal statement, e.g. `return`, `raise`, `continue`, `break`
|
|
115
|
+
| DC | ignore-expression | Do not show any findings for an expression, which starts on current line (this code can only be used in `# noqa: DC` comments)
|
|
94
116
|
|
|
95
117
|
## Ignoring checks with noqa comments
|
|
96
118
|
Inline `# noqa` comments can be used to ignore `deadcode` checks.
|
|
97
|
-
E.g. unused `Foo` class wont be detected/fixed because `# noqa:
|
|
119
|
+
E.g. unused `Foo` class wont be detected/fixed because `# noqa: DC03` comment is used:
|
|
98
120
|
|
|
99
121
|
```python
|
|
100
|
-
class Foo: # noqa:
|
|
122
|
+
class Foo: # noqa: DC03
|
|
101
123
|
pass
|
|
102
124
|
```
|
|
103
125
|
|
|
@@ -127,10 +149,10 @@ code base is implemented in.
|
|
|
127
149
|
|
|
128
150
|
## Feature requests
|
|
129
151
|
- [x] Replace `.*` with only `*` in regexp matching.
|
|
130
|
-
- [x] Add unused class method detection
|
|
152
|
+
- [x] Add unused class method detection DC04 check.
|
|
131
153
|
- [x] Add `--fix` option to automatically remove detected dead code occourencies
|
|
132
154
|
- [x] Add a check for empty python files.
|
|
133
|
-
- [x] Split error codes into
|
|
155
|
+
- [x] Split error codes into DC01, DC02, DC03 for variables, functions, class.
|
|
134
156
|
- [x] Should have different codes for ignoring name and ignoring whole definition (reserved DCxx0 - ignore name, DCxx1 - ignore definition).
|
|
135
157
|
- [ ] Allow to disable each check separately using:
|
|
136
158
|
- [ ] inline comment.
|
|
@@ -144,4 +166,28 @@ code base is implemented in.
|
|
|
144
166
|
- [ ] --ignore-definitions-if-decorated-with
|
|
145
167
|
- [ ] --ignore-names-if-inherits-from
|
|
146
168
|
- [ ] --ignore-names-if-decorated-with
|
|
169
|
+
- [ ] --ignore-bodies-of
|
|
170
|
+
- [ ] --ignore-bodies-if-decorated-with
|
|
171
|
+
- [ ] --ignore-bodies-if-inherits-from
|
|
172
|
+
- [ ] --ignore-definitions
|
|
173
|
+
- [ ] --ignore-definitions-if-inherits-from
|
|
174
|
+
- [ ] --ignore-definitions-if-decorated-with
|
|
175
|
+
- Question: would it be possible to ignore only certain types of checks for a body, e.g. only variable attributes of TypedDict and still check usage of methods and properties?
|
|
176
|
+
- What expression would allow this type of precission?
|
|
147
177
|
- [ ] Distinguish between definitions with same name, but different files.
|
|
178
|
+
- [ ] Repeated application of `deadcode` till the output stops changing.
|
|
179
|
+
- [ ] Unreachable code detection and fixing: this should only be scoped for if statements and only limited to primitive variables.
|
|
180
|
+
- [ ] `--fix --dry [filenames]` - only show whats about to change in the listed filenames.
|
|
181
|
+
- [ ] Benchmarking performance with larger projects (time, CPU and memory consumption) in order to optimize.
|
|
182
|
+
- [ ] `--fix` could accept a list of filenames as well (only those files would be changed, but the summary could would be full).
|
|
183
|
+
(This might be confusing, because filenames, which have to be considered are provided without any flag, --fix is expected to not accept arguments)
|
|
184
|
+
- [ ] pre-commit-hook.
|
|
185
|
+
- [ ] language server.
|
|
186
|
+
- [ ] Use only two digits for error codes instead of 3. Two is plenty and it simplifies usage a bit
|
|
187
|
+
- [ ] DC10: remove code after terminal statements like `raise`, `return`, `break`, `continue` and comes in the same scope.
|
|
188
|
+
- [ ] Add `ignore` and `per-file-ignores` command line and pyproject.toml options, which allows to skip some rules.
|
|
189
|
+
- [ ] Make sure that all rules are being skipped by `noqa` comment and all rules react to `noqa: rule_id` comments.
|
|
190
|
+
- [ ] Include package names into code item scope (dot-separated path), e.g. "package1.package2.module.class.method.variable".
|
|
191
|
+
- [ ] All options should be able to accept dot-separated path or a generic name, e.g. "marshmallow.Schema" vs "Schema",
|
|
192
|
+
documentation should cleary demonstrate the behaviour/example that "Schema" means "*.Schema".
|
|
193
|
+
- [ ] Redefinition of an existing name makes previous name unreachable, unless it is assigned somehow.
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
[](https://deadcode.readthedocs.io/en/stable/)
|
|
2
|
+
|
|
3
|
+
<h2 align="center">Find and Fix Unused Python Code</h2>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://github.com/albertas/deadcode/blob/main/LICENSE"><img alt="License: AGPLv3" src="https://raw.githubusercontent.com/albertas/deadcode/main/docs/_static/AGPLv3-license.svg"></a>
|
|
7
|
+
<a href="https://pypi.org/project/deadcode/"><img alt="PyPI" src="https://img.shields.io/pypi/v/deadcode"></a>
|
|
8
|
+
<a href="https://pepy.tech/project/deadcode"><img alt="Downloads" src="https://static.pepy.tech/badge/deadcode"></a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
5
11
|
|
|
6
12
|
## Installation
|
|
7
13
|
```shell
|
|
@@ -9,11 +15,27 @@ pip install deadcode
|
|
|
9
15
|
```
|
|
10
16
|
|
|
11
17
|
## Usage
|
|
18
|
+
To see unused code findings:
|
|
12
19
|
```shell
|
|
13
20
|
deadcode .
|
|
14
21
|
```
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
To see suggested fixes for all files:
|
|
24
|
+
```shell
|
|
25
|
+
deadcode . --fix --dry
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
To see suggested fixes for only `foo.py` file:
|
|
29
|
+
```shell
|
|
30
|
+
deadcode . --fix --dry foo.py
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
To fix:
|
|
34
|
+
```shell
|
|
35
|
+
deadcode . --fix
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Tune out some of the false positives, e.g.:
|
|
17
39
|
```
|
|
18
40
|
deadcode . --exclude=venv,tests --ignore-names=BaseTestCase,*Mixin --ignore-names-in-files=migrations
|
|
19
41
|
```
|
|
@@ -31,6 +53,7 @@ ignore-names-in-files = ["migrations"]
|
|
|
31
53
|
| Option | Type | Meaning |
|
|
32
54
|
|-------------------------------------------|------|----------------------------------------------------------------------|
|
|
33
55
|
|`--fix` | - | Automatically remove detected unused code expressions from the code base. |
|
|
56
|
+
|`--dry` | - or list | Show changes which would be made in files. Shows changes for provided filenames or shows all changes if no filename is specified. |
|
|
34
57
|
|`--exclude` | list | Filenames (or path expressions), which will be completely skipped without being analysed. |
|
|
35
58
|
|`--ignore-names` | list | Removes provided list of names from the output. Regexp expressions to match multiple names can also be provided, e.g. `*Mixin` will match all classes ending with `Mixin`. |
|
|
36
59
|
|`--ignore-names-in-files` | list | Ignores unused names in files, which filenames match provided path expressions. |
|
|
@@ -56,27 +79,26 @@ definition - whole class or function definition expression including its name an
|
|
|
56
79
|
## Rules
|
|
57
80
|
| Code | Name | Message |
|
|
58
81
|
|--------|--------------------|----------------|
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
72
|
-
`*` - are not yet implemented rules.
|
|
82
|
+
| DC01 | unused-variable | Variable `{name}` is never used
|
|
83
|
+
| DC02 | unused-function | Function `{name}` is never used
|
|
84
|
+
| DC03 | unused-class | Class `{name}` is never used
|
|
85
|
+
| DC04 | unused-method | Method `{name}` is never used
|
|
86
|
+
| DC05 | unused-attribute | Attribute `{name}` is never used
|
|
87
|
+
| DC06 | unused-name | Name `{name}` is never used
|
|
88
|
+
| DC07 | unused-import | Import `{name}` is never used
|
|
89
|
+
| DC08 | unused-property | Property `{name}` is never used
|
|
90
|
+
| DC09 | unreachable-if-block | Unreachable conditional statement block
|
|
91
|
+
| DC11 | empty-file | Empty Python file
|
|
92
|
+
| DC12 | commented-out-code | Commented out code
|
|
93
|
+
| DC13 | unreachable-code | Code after terminal statement, e.g. `return`, `raise`, `continue`, `break`
|
|
94
|
+
| DC | ignore-expression | Do not show any findings for an expression, which starts on current line (this code can only be used in `# noqa: DC` comments)
|
|
73
95
|
|
|
74
96
|
## Ignoring checks with noqa comments
|
|
75
97
|
Inline `# noqa` comments can be used to ignore `deadcode` checks.
|
|
76
|
-
E.g. unused `Foo` class wont be detected/fixed because `# noqa:
|
|
98
|
+
E.g. unused `Foo` class wont be detected/fixed because `# noqa: DC03` comment is used:
|
|
77
99
|
|
|
78
100
|
```python
|
|
79
|
-
class Foo: # noqa:
|
|
101
|
+
class Foo: # noqa: DC03
|
|
80
102
|
pass
|
|
81
103
|
```
|
|
82
104
|
|
|
@@ -106,10 +128,10 @@ code base is implemented in.
|
|
|
106
128
|
|
|
107
129
|
## Feature requests
|
|
108
130
|
- [x] Replace `.*` with only `*` in regexp matching.
|
|
109
|
-
- [x] Add unused class method detection
|
|
131
|
+
- [x] Add unused class method detection DC04 check.
|
|
110
132
|
- [x] Add `--fix` option to automatically remove detected dead code occourencies
|
|
111
133
|
- [x] Add a check for empty python files.
|
|
112
|
-
- [x] Split error codes into
|
|
134
|
+
- [x] Split error codes into DC01, DC02, DC03 for variables, functions, class.
|
|
113
135
|
- [x] Should have different codes for ignoring name and ignoring whole definition (reserved DCxx0 - ignore name, DCxx1 - ignore definition).
|
|
114
136
|
- [ ] Allow to disable each check separately using:
|
|
115
137
|
- [ ] inline comment.
|
|
@@ -123,4 +145,28 @@ code base is implemented in.
|
|
|
123
145
|
- [ ] --ignore-definitions-if-decorated-with
|
|
124
146
|
- [ ] --ignore-names-if-inherits-from
|
|
125
147
|
- [ ] --ignore-names-if-decorated-with
|
|
148
|
+
- [ ] --ignore-bodies-of
|
|
149
|
+
- [ ] --ignore-bodies-if-decorated-with
|
|
150
|
+
- [ ] --ignore-bodies-if-inherits-from
|
|
151
|
+
- [ ] --ignore-definitions
|
|
152
|
+
- [ ] --ignore-definitions-if-inherits-from
|
|
153
|
+
- [ ] --ignore-definitions-if-decorated-with
|
|
154
|
+
- Question: would it be possible to ignore only certain types of checks for a body, e.g. only variable attributes of TypedDict and still check usage of methods and properties?
|
|
155
|
+
- What expression would allow this type of precission?
|
|
126
156
|
- [ ] Distinguish between definitions with same name, but different files.
|
|
157
|
+
- [ ] Repeated application of `deadcode` till the output stops changing.
|
|
158
|
+
- [ ] Unreachable code detection and fixing: this should only be scoped for if statements and only limited to primitive variables.
|
|
159
|
+
- [ ] `--fix --dry [filenames]` - only show whats about to change in the listed filenames.
|
|
160
|
+
- [ ] Benchmarking performance with larger projects (time, CPU and memory consumption) in order to optimize.
|
|
161
|
+
- [ ] `--fix` could accept a list of filenames as well (only those files would be changed, but the summary could would be full).
|
|
162
|
+
(This might be confusing, because filenames, which have to be considered are provided without any flag, --fix is expected to not accept arguments)
|
|
163
|
+
- [ ] pre-commit-hook.
|
|
164
|
+
- [ ] language server.
|
|
165
|
+
- [ ] Use only two digits for error codes instead of 3. Two is plenty and it simplifies usage a bit
|
|
166
|
+
- [ ] DC10: remove code after terminal statements like `raise`, `return`, `break`, `continue` and comes in the same scope.
|
|
167
|
+
- [ ] Add `ignore` and `per-file-ignores` command line and pyproject.toml options, which allows to skip some rules.
|
|
168
|
+
- [ ] Make sure that all rules are being skipped by `noqa` comment and all rules react to `noqa: rule_id` comments.
|
|
169
|
+
- [ ] Include package names into code item scope (dot-separated path), e.g. "package1.package2.module.class.method.variable".
|
|
170
|
+
- [ ] All options should be able to accept dot-separated path or a generic name, e.g. "marshmallow.Schema" vs "Schema",
|
|
171
|
+
documentation should cleary demonstrate the behaviour/example that "Schema" means "*.Schema".
|
|
172
|
+
- [ ] Redefinition of an existing name makes previous name unreachable, unless it is assigned somehow.
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import re
|
|
3
|
+
import shlex
|
|
4
|
+
import shutil
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from subprocess import PIPE, STDOUT, run
|
|
8
|
+
from typing import Union
|
|
9
|
+
|
|
10
|
+
ACTION_PATH = Path(os.environ["GITHUB_ACTION_PATH"])
|
|
11
|
+
ENV_PATH = ACTION_PATH / ".black-env"
|
|
12
|
+
ENV_BIN = ENV_PATH / ("Scripts" if sys.platform == "win32" else "bin")
|
|
13
|
+
OPTIONS = os.getenv("INPUT_OPTIONS", default="")
|
|
14
|
+
SRC = os.getenv("INPUT_SRC", default="")
|
|
15
|
+
JUPYTER = os.getenv("INPUT_JUPYTER") == "true"
|
|
16
|
+
BLACK_ARGS = os.getenv("INPUT_BLACK_ARGS", default="")
|
|
17
|
+
VERSION = os.getenv("INPUT_VERSION", default="")
|
|
18
|
+
USE_PYPROJECT = os.getenv("INPUT_USE_PYPROJECT") == "true"
|
|
19
|
+
|
|
20
|
+
BLACK_VERSION_RE = re.compile(r"^black([^A-Z0-9._-]+.*)$", re.IGNORECASE)
|
|
21
|
+
EXTRAS_RE = re.compile(r"\[.*\]")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def determine_version_specifier() -> str:
|
|
25
|
+
"""Determine the version of Black to install.
|
|
26
|
+
|
|
27
|
+
The version can be specified either via the `with.version` input or via the
|
|
28
|
+
pyproject.toml file if `with.use_pyproject` is set to `true`.
|
|
29
|
+
"""
|
|
30
|
+
if USE_PYPROJECT and VERSION:
|
|
31
|
+
print(
|
|
32
|
+
"::error::'with.version' and 'with.use_pyproject' inputs are "
|
|
33
|
+
"mutually exclusive.",
|
|
34
|
+
file=sys.stderr,
|
|
35
|
+
flush=True,
|
|
36
|
+
)
|
|
37
|
+
sys.exit(1)
|
|
38
|
+
if USE_PYPROJECT:
|
|
39
|
+
return read_version_specifier_from_pyproject()
|
|
40
|
+
elif VERSION and VERSION[0] in "0123456789":
|
|
41
|
+
return f"=={VERSION}"
|
|
42
|
+
else:
|
|
43
|
+
return VERSION
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def read_version_specifier_from_pyproject() -> str:
|
|
47
|
+
if sys.version_info < (3, 11):
|
|
48
|
+
print(
|
|
49
|
+
"::error::'with.use_pyproject' input requires Python 3.11 or later.",
|
|
50
|
+
file=sys.stderr,
|
|
51
|
+
flush=True,
|
|
52
|
+
)
|
|
53
|
+
sys.exit(1)
|
|
54
|
+
|
|
55
|
+
import tomllib # type: ignore[import-not-found,unreachable]
|
|
56
|
+
|
|
57
|
+
try:
|
|
58
|
+
with Path("pyproject.toml").open("rb") as fp:
|
|
59
|
+
pyproject = tomllib.load(fp)
|
|
60
|
+
except FileNotFoundError:
|
|
61
|
+
print(
|
|
62
|
+
"::error::'with.use_pyproject' input requires a pyproject.toml file.",
|
|
63
|
+
file=sys.stderr,
|
|
64
|
+
flush=True,
|
|
65
|
+
)
|
|
66
|
+
sys.exit(1)
|
|
67
|
+
|
|
68
|
+
version = pyproject.get("tool", {}).get("black", {}).get("required-version")
|
|
69
|
+
if version is not None:
|
|
70
|
+
return f"=={version}"
|
|
71
|
+
|
|
72
|
+
arrays = [
|
|
73
|
+
pyproject.get("project", {}).get("dependencies"),
|
|
74
|
+
*pyproject.get("project", {}).get("optional-dependencies", {}).values(),
|
|
75
|
+
]
|
|
76
|
+
for array in arrays:
|
|
77
|
+
version = find_black_version_in_array(array)
|
|
78
|
+
if version is not None:
|
|
79
|
+
break
|
|
80
|
+
|
|
81
|
+
if version is None:
|
|
82
|
+
print(
|
|
83
|
+
"::error::'black' dependency missing from pyproject.toml.",
|
|
84
|
+
file=sys.stderr,
|
|
85
|
+
flush=True,
|
|
86
|
+
)
|
|
87
|
+
sys.exit(1)
|
|
88
|
+
|
|
89
|
+
return version
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def find_black_version_in_array(array: object) -> Union[str, None]:
|
|
93
|
+
if not isinstance(array, list):
|
|
94
|
+
return None
|
|
95
|
+
try:
|
|
96
|
+
for item in array:
|
|
97
|
+
# Rudimentary PEP 508 parsing.
|
|
98
|
+
item = item.split(";")[0]
|
|
99
|
+
item = EXTRAS_RE.sub("", item).strip()
|
|
100
|
+
if item == "black":
|
|
101
|
+
print(
|
|
102
|
+
"::error::Version specifier missing for 'black' dependency in "
|
|
103
|
+
"pyproject.toml.",
|
|
104
|
+
file=sys.stderr,
|
|
105
|
+
flush=True,
|
|
106
|
+
)
|
|
107
|
+
sys.exit(1)
|
|
108
|
+
elif m := BLACK_VERSION_RE.match(item):
|
|
109
|
+
return m.group(1).strip()
|
|
110
|
+
except TypeError:
|
|
111
|
+
pass
|
|
112
|
+
|
|
113
|
+
return None
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
run([sys.executable, "-m", "venv", str(ENV_PATH)], check=True)
|
|
117
|
+
|
|
118
|
+
version_specifier = determine_version_specifier()
|
|
119
|
+
if JUPYTER:
|
|
120
|
+
extra_deps = "[colorama,jupyter]"
|
|
121
|
+
else:
|
|
122
|
+
extra_deps = "[colorama]"
|
|
123
|
+
if version_specifier:
|
|
124
|
+
req = f"black{extra_deps}{version_specifier}"
|
|
125
|
+
else:
|
|
126
|
+
describe_name = ""
|
|
127
|
+
with open(ACTION_PATH / ".git_archival.txt", encoding="utf-8") as fp:
|
|
128
|
+
for line in fp:
|
|
129
|
+
if line.startswith("describe-name: "):
|
|
130
|
+
describe_name = line[len("describe-name: ") :].rstrip()
|
|
131
|
+
break
|
|
132
|
+
if not describe_name:
|
|
133
|
+
print("::error::Failed to detect action version.", file=sys.stderr, flush=True)
|
|
134
|
+
sys.exit(1)
|
|
135
|
+
# expected format is one of:
|
|
136
|
+
# - 23.1.0
|
|
137
|
+
# - 23.1.0-51-g448bba7
|
|
138
|
+
if describe_name.count("-") < 2:
|
|
139
|
+
# the action's commit matches a tag exactly, install exact version from PyPI
|
|
140
|
+
req = f"black{extra_deps}=={describe_name}"
|
|
141
|
+
else:
|
|
142
|
+
# the action's commit does not match any tag, install from the local git repo
|
|
143
|
+
req = f".{extra_deps}"
|
|
144
|
+
print(f"Installing {req}...", flush=True)
|
|
145
|
+
pip_proc = run(
|
|
146
|
+
[str(ENV_BIN / "python"), "-m", "pip", "install", req],
|
|
147
|
+
stdout=PIPE,
|
|
148
|
+
stderr=STDOUT,
|
|
149
|
+
encoding="utf-8",
|
|
150
|
+
cwd=ACTION_PATH,
|
|
151
|
+
)
|
|
152
|
+
if pip_proc.returncode:
|
|
153
|
+
print(pip_proc.stdout)
|
|
154
|
+
print("::error::Failed to install Black.", file=sys.stderr, flush=True)
|
|
155
|
+
sys.exit(pip_proc.returncode)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
base_cmd = [str(ENV_BIN / "black")]
|
|
159
|
+
if BLACK_ARGS:
|
|
160
|
+
# TODO: remove after a while since this is deprecated in favour of SRC + OPTIONS.
|
|
161
|
+
proc = run(
|
|
162
|
+
[*base_cmd, *shlex.split(BLACK_ARGS)],
|
|
163
|
+
stdout=PIPE,
|
|
164
|
+
stderr=STDOUT,
|
|
165
|
+
encoding="utf-8",
|
|
166
|
+
)
|
|
167
|
+
else:
|
|
168
|
+
proc = run(
|
|
169
|
+
[*base_cmd, *shlex.split(OPTIONS), *shlex.split(SRC)],
|
|
170
|
+
stdout=PIPE,
|
|
171
|
+
stderr=STDOUT,
|
|
172
|
+
encoding="utf-8",
|
|
173
|
+
)
|
|
174
|
+
shutil.rmtree(ENV_PATH, ignore_errors=True)
|
|
175
|
+
print(proc.stdout)
|
|
176
|
+
sys.exit(proc.returncode)
|