Skip to content

Commit

Permalink
Fix: ignore-init setting is not working from command line call #263
Browse files Browse the repository at this point in the history
  • Loading branch information
hakancelikdev committed Jul 6, 2023
1 parent f058695 commit f26c6b3
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
- id: isort

- repo: https://github.com/hakancelikdev/unimport
rev: 0.16.0
rev: 0.16.1
hooks:
- id: unimport

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/use-with-github-action.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
```
2 changes: 1 addition & 1 deletion src/unimport/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.16.0"
__version__ = "0.16.1"
__description__ = "A linter, formatter for finding and removing unused import statements."
2 changes: 1 addition & 1 deletion src/unimport/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
22 changes: 21 additions & 1 deletion tests/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down Expand Up @@ -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})

Expand Down

0 comments on commit f26c6b3

Please sign in to comment.