Skip to content

Commit

Permalink
Merge pull request #18 from MichaelKim0407/develop
Browse files Browse the repository at this point in the history
release 1.3
  • Loading branch information
MichaelKim0407 committed Oct 21, 2021
2 parents 46a5139 + d8db1e6 commit d736b54
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -62,6 +62,11 @@ or set `percent-greedy=<level>` and `format-greedy=<level>` in the `.flake8` con

This plugin can also check for strings that appear to be f-strings but don't have the `f` prefix.

`FS003` will be reported if a string:
* is not prefixed with `f`
* contains at least one pair of `{}`
* is not prefixed with `r` (because r-strings are often regexes that would contain `{}`)

Due to the potential for false positives, this check (`FS003`) is disabled by default.
To enable this check,
add the `--enable-extensions=FS003` command line option,
Expand Down
2 changes: 1 addition & 1 deletion flake8_use_fstring/__init__.py
@@ -1 +1 @@
__version__ = '1.2.1'
__version__ = '1.3'
3 changes: 2 additions & 1 deletion flake8_use_fstring/prefix.py
Expand Up @@ -13,7 +13,8 @@

FSTRING_REGEX = _re.compile(r'^([a-zA-Z]*?[fF][a-zA-Z]*?){1}["\']')
NON_FSTRING_REGEX = _re.compile(
r'^[a-zA-Z]*(?:\'\'\'|\'|"""|")(.*?{.+?}.*)(?:\'|\'\'\'|"|""")$',
r'^[a-zA-Z]*(?<!\b[rR])(?:\'\'\'|\'|"""|")'
r'(.*?{.+?}.*)(?:\'|\'\'\'|"|""")$',
)


Expand Down
3 changes: 2 additions & 1 deletion tests/example.py
Expand Up @@ -47,7 +47,8 @@ def format(self): # noqa: A003

# match missing prefix
o = ('{n}'
'{{m}} {n}')
'{{m}} {n}'
r'[a-z]{1,3}') # Should not be matched.

# no errors below; coverage
''.strip()

0 comments on commit d736b54

Please sign in to comment.