Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Autofix error] - self.assertIsNotNone one-liner with if/else #3060

Closed
bmrobin opened this issue Feb 20, 2023 · 1 comment · Fixed by #3062
Closed

[Autofix error] - self.assertIsNotNone one-liner with if/else #3060

bmrobin opened this issue Feb 20, 2023 · 1 comment · Fixed by #3062
Labels
bug Something isn't working

Comments

@bmrobin
Copy link

bmrobin commented Feb 20, 2023

the following one-liner fails to autofix and causes the syntax error message to be thrown

# original code
self.assertIsNotNone(value) if expect_condition else self.assertIsNone(value)

# suitable work-around i did to get unblocked
if expect_condition:
    assert value is not None
else:
    assert value is None

this was on ruff version 0.0.247

here are my ruff settings in pyproject.toml

[tool.ruff]
line-length = 120
target-version = "py310"
format = "grouped"
extend-exclude = [
    "__pycache__",
    "__init__.py",
]
show-source = true
select = [
    "E", "F", # Flake8 (pycodestyle + pyflakes)
    "I",      # isort (import sorting)
    #"ANN",   # flake8-annotations (type annotations)
    # "S",    # flake8-bandit (security)
    "B",      # flake8-bugbear (sneaky silent bugs)
    "A",      # flake8-builtins (reserved keyword usage)
    "PT",     # flake8-pytest-style (pytest-specific linting)
    "Q",      # flake8-quotes (single vs. double quotes)
    "ARG",    # flake8-unused-arguments (unused function arguments)
    "DTZ",    # flake8-datetimez (naive datetime usage)
    "RUF",    # ruff (ruff-specific linting)
]
ignore = [
    "RUF001",
    "RUF002",
    "RUF003",
    "RUF005",
    "E731",
    "PT001",
    "PT006",
    "PT023",
    "B904",
    "E722",
]

love the tool, thanks for all the hard (great) work!

@charliermarsh charliermarsh added the bug Something isn't working label Feb 20, 2023
@charliermarsh
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants