Skip to content

Commit

Permalink
feat!: rename 'notc' tokens to become 'noqa'
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Any previous 'notc' token will stop working. Now you must
use 'noqa' instead, which keeps consistent with flake8 standards
  • Loading branch information
guilatrova committed Jul 21, 2021
1 parent 21a0394 commit 0a2c1c5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ All violations and its descriptions can be found in [docs](https://github.com/gu

If you want to ignore a violation in a specific file, you can either:

- Add a comment with `notc` to the top of the file you want to ignore
- Add a comment with `notc` to the line you want to ignore
- Add a comment with `notc: CODE` to the line you want to ignore a specific violation
- Add a comment with `noqa` to the top of the file you want to ignore
- Add a comment with `noqa` to the line you want to ignore
- Add a comment with `noqa: CODE` to the line you want to ignore a specific violation

Example:

Expand All @@ -105,7 +105,7 @@ def verbose_reraise_1():
try:
a = 1
except Exception as ex:
raise ex # notc: TC202
raise ex # noqa: TC202
```

### Configuration
Expand Down
4 changes: 2 additions & 2 deletions src/tests/samples/ignore_comments/ignore_file.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# notc
# noqa
class MyException(Exception):
pass

Expand All @@ -24,7 +24,7 @@ def verbose_reraise_2():

def too_many_try():
try:
a = 1 # notc <- it doesnt matter because I ignored the whole file
a = 1 # noqa <- it doesnt matter because I ignored the whole file
except Exception:
raise

Expand Down
6 changes: 3 additions & 3 deletions src/tests/samples/ignore_comments/ignore_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def verbose_reraise_1():
except (NotImplementedError, ValueError) as ex:
raise
except Exception as ex:
raise ex # notc
raise ex # noqa


def verbose_reraise_2():
try:
a = 1
except Exception as ex:
if a == 1:
raise ex # notc
raise ex # noqa


def too_many_try():
Expand All @@ -27,7 +27,7 @@ def too_many_try():
except Exception:
raise

try: # notc
try: # noqa
b = 2
except Exception:
raise
6 changes: 3 additions & 3 deletions src/tests/samples/ignore_comments/ignore_line_specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def verbose_reraise_1():
except (NotImplementedError, ValueError) as ex:
raise
except Exception as ex:
raise ex # notc: TC202
raise ex # noqa: TC202


def verbose_reraise_2():
try:
a = 1
except Exception as ex:
if a == 1:
raise ex # notc: TC202, TC200, TC201 I want to skip
raise ex # noqa: TC202, TC200, TC201 I want to skip


def too_many_try():
Expand All @@ -27,7 +27,7 @@ def too_many_try():
except Exception:
raise

try: # notc:TC101 this is not a big deal
try: # noqa:TC101 this is not a big deal
b = 2
except Exception:
raise
4 changes: 2 additions & 2 deletions src/tryceratops/files/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from tryceratops.filters import FileFilter, IgnoreViolation

IGNORE_TRYCERATOPS_TOKEN = "notc"
IGNORE_TOKEN_PATT = r"notc(: ?((TC\d{3},? ?)+))?"
IGNORE_TRYCERATOPS_TOKEN = "noqa"
IGNORE_TOKEN_PATT = r"noqa(: ?((TC\d{3},? ?)+))?"


def _build_ignore_line(match: re.Match, location: Tuple[int, int]) -> IgnoreViolation:
Expand Down

0 comments on commit 0a2c1c5

Please sign in to comment.