generated from ShigureLab/python-lib-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: add pragma
dochooks: skip-line
and `dochooks: skip-next-lin…
…e` to suppressing lint error (#46) * ✨ feat: add pragma `dochooks: skip-line` and `dochooks: skip-next-line` to suppressing lint error * Update README.md Co-authored-by: ooo oo <[email protected]> --------- Co-authored-by: ooo oo <[email protected]>
- Loading branch information
1 parent
15d9ceb
commit b3cea43
Showing
4 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
dochooks/insert_whitespace_between_cn_and_en_char/pragma.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from __future__ import annotations | ||
|
||
from contextlib import contextmanager | ||
from enum import Enum | ||
|
||
|
||
class Pragma(Enum): | ||
SKIP_NEXT_LINE = "dochooks: skip-next-line" | ||
SKIP_LINE = "dochooks: skip-line" | ||
|
||
|
||
class PragmaManager: | ||
def __init__(self): | ||
self.skip_line = False | ||
|
||
@contextmanager | ||
def scan(self, line: str): | ||
if Pragma.SKIP_LINE.value in line: | ||
self.skip_line = True | ||
yield self.skip_line | ||
self.skip_line = False | ||
if Pragma.SKIP_NEXT_LINE.value in line: | ||
self.skip_line = True |