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

Add config option for uses_only_args_and_local_vars/allow_external_class_usage #19

Open
dogweather opened this issue Jul 5, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@dogweather
Copy link

dogweather commented Jul 5, 2022

Is your feature request related to a problem? Please describe.

I get these errors on my "pure" functions:

_combine is not pure because of:
	it uses external name (entries)
	it uses external name (Language)
	it uses external name (phrase)
	it uses external name (defn)
	it uses external name (lang)
	it uses external name (Definition)

IMO, these are false positives. It looks like setting allow_external_class_usage to True would resolve some of these. (?) The option was coded, but not accessible from the CLI.

Some, though, seem to be an inability to understand Python 3.10 match and type hints:

def _combine(*entries: Iterable[Entry]) -> Iterable[Entry]:
    """Combine single-entry terms with the same phrase."""

    all_entries = cast(Iterable[Entry], concat(entries))

    term_dict: dict[tuple[str, Language], list[Definition]] = defaultdict(list)

    for entry in sorted(all_entries):
        match(entry.definitions):
            case [defn]:
                key = (entry.phrase, entry.language)
                term_dict[key].append(defn)
            case _:
                raise ValueError(f"Entry expected to have exactly one definition: {entry}")

    for (phrase, lang), defns in term_dict.items():
        yield Entry(phrase, defns, lang)
@dogweather dogweather added the enhancement New feature or request label Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant