diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 13b8422c..72a66ab7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: isort - repo: https://github.com/hakancelikdev/unimport - rev: 0.16.0 + rev: 0.16.1 hooks: - id: unimport diff --git a/action.yml b/action.yml index aee29e77..0ec92fe4 100644 --- a/action.yml +++ b/action.yml @@ -10,7 +10,7 @@ inputs: runs: using: "composite" steps: - - run: pip install --upgrade pip && python -m pip install unimport==0.16.0 + - run: pip install --upgrade pip && python -m pip install unimport==0.16.1 shell: bash - run: unimport --color auto --gitignore --ignore-init ${{ inputs.extra_args }} shell: bash diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index da9beb7c..9796d4e2 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. ## [Unreleased] - YYYY-MM-DD +## [0.16.1] - 2023-07-05 + +### Fixed + +- Fix: ignore-init setting is not working from command line call + [#263](https://github.com/hakancelikdev/unimport/issues/263) + ## [0.16.0] - 2023-04-04 ### Added diff --git a/docs/tutorial/use-with-github-action.md b/docs/tutorial/use-with-github-action.md index 2021ec0b..4c613e69 100644 --- a/docs/tutorial/use-with-github-action.md +++ b/docs/tutorial/use-with-github-action.md @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 - name: Check unused imports - uses: hakancelikdev/unimport@0.16.0 + uses: hakancelikdev/unimport@0.16.1 with: extra_args: --include src/ ``` diff --git a/src/unimport/__init__.py b/src/unimport/__init__.py index a6812378..c8938839 100644 --- a/src/unimport/__init__.py +++ b/src/unimport/__init__.py @@ -1,2 +1,2 @@ -__version__ = "0.16.0" +__version__ = "0.16.1" __description__ = "A linter, formatter for finding and removing unused import statements." diff --git a/src/unimport/config.py b/src/unimport/config.py index c72e694c..2f4aea55 100644 --- a/src/unimport/config.py +++ b/src/unimport/config.py @@ -93,7 +93,7 @@ def __post_init__(self): if self.gitignore: self.gitignore_patterns = utils.get_exclude_list_from_gitignore() - elif self.ignore_init: + if self.ignore_init: self.exclude = "|".join([self.exclude, C.INIT_FILE_IGNORE_REGEX]) def get_paths(self) -> Iterator[Path]: diff --git a/tests/config/test_config.py b/tests/config/test_config.py index 6910498f..73f6e5e0 100644 --- a/tests/config/test_config.py +++ b/tests/config/test_config.py @@ -97,7 +97,8 @@ def test_parse_config_parse_args_config_setup_cfg(): def test_parse_config_parse_args(argv: List[str], expected_argv: str, attribute_name: str): parser = generate_parser() args = parser.parse_args(argv) - config = ParseConfig.parse_args(parser.parse_args(argv)) + args.disable_auto_discovery_config = True + config = ParseConfig.parse_args(args) assert getattr(config, attribute_name) == expected_argv, f"args: {args}, attribute_name: {attribute_name}" @@ -127,6 +128,25 @@ def test_config_build_default_command_diff(): assert Config.build(args={"permission": True}).diff is True +def test_config_build_command_ignore_init(): + config = Config.build() + + assert config.ignore_init is False + assert config.exclude == "^$" + + c = Config.build(args={"ignore_init": True}) + assert c.ignore_init is True + assert c.exclude == "^$|__init__\\.py" + + c = Config.build(args={"gitignore": True}) + assert c.ignore_init is False + assert c.exclude == "^$" + + c = Config.build(args={"gitignore": True, "ignore_init": True}) + assert c.ignore_init is True + assert c.exclude == "^$|__init__\\.py" + + def test_config_build_default_remove(): config = Config.build(args={"disable_auto_discovery_config": True})