Skip to content

Commit

Permalink
Upgrade to libcst >= 1.0.0 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljodal authored Jul 18, 2023
1 parent e1ce03b commit e5558a3
Show file tree
Hide file tree
Showing 5 changed files with 286 additions and 296 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Upgrade to libcst >= 1.0.0

## [0.2.0] - 2023-05-04

### Added
Expand Down
10 changes: 8 additions & 2 deletions oida/config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,18 @@ def update_allowed_imports_statement(

if node.value and m.matches(node.value, m.Set()):
value = ensure_type(node.value, cst.Set)
current_rules: set[str] = {
current_rules = {
ensure_type(element.value, cst.SimpleString).evaluated_value
for element in value.elements
}

updated_rules = update_allowed_imports(current_rules, violations)
# Make sure all items in the set where string literals
if not all(isinstance(rule, str) for rule in current_rules):
raise ValueError("Found bytes literal in ALLOWED_IMPORTS setting")

updated_rules = update_allowed_imports(
cast(set[str], current_rules), violations
)

new_elements = [
element
Expand Down
4 changes: 0 additions & 4 deletions oida/console.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import argparse
import os
import sys
from pathlib import Path

Expand Down Expand Up @@ -57,9 +56,6 @@ def main() -> None:

args = parser.parse_args()

# Needed to parse Python 3.10 documents
os.environ.setdefault("LIBCST_PARSER_TYPE", "native")

if args.command == "lint":
if not run_linter(*args.paths, checks=args.checks):
sys.exit(1)
Expand Down
Loading

0 comments on commit e5558a3

Please sign in to comment.