question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support wildcard references to modules in contracts

See original GitHub issue

I have this directory structure: https://github.com/wemake-services/wemake-python-styleguide/tree/ae821ddb0b9c234870953ed5a17cd3858a52ee3c/wemake_python_styleguide/visitors

Every module in any module should be respect type = independent contract. But, I have like dozens of modules, and new ones are created like once a week.

What do I want? I want to enforce independent contract on all modules in a package and sub-packages. And mark several exceptions: base and decorators in my case. Something like this:

[importlinter:contract:independence]
name = Independence contract (all shall be free!)
type = independence

modules =
  wemake_python_styleguide.visitors.**.*
  # Or at least something like this will do:
  wemake_python_styleguide.visitors.ast.*
  wemake_python_styleguide.visitors.tokenize.*
  wemake_python_styleguide.visitors.filenames.*
ignore_imports =
  # It is ok to be related on these modules:
  wemake_python_styleguide.visitors.base
  wemake_python_styleguide.visitors.decorators

Is it possible? Original issue: https://github.com/wemake-services/wemake-python-styleguide/issues/720

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
seddonymcommented, May 21, 2020

I will try to prepare initial implementation in following weeks

Thanks @skarzi. You should be able to do this without any changes to core import-linter by implementing a custom contract and field type: https://import-linter.readthedocs.io/en/latest/custom_contract_types.html

Of course I’d be happy to consider a PR to core import-linter, but it’s worth knowing that you hopefully don’t need anything from me in order to make this possible.

Let me know how you get on!

1reaction
sobolevncommented, Jul 29, 2019

@seddonym this is an awesome project to contribute to, but sadly I dont’ have enough time to work on it right now. I have a big release of wemake-python-styleguide in a month. 😞

Read more comments on GitHub >

github_iconTop Results From Across the Web

passing dictionary of wildcard constraints from config file
I am constructing a snakemake pipeline. I have a config.yaml file in which I want to store wildcard constraints ...
Read more >
Python static code analysis: Wildcard imports should not be ...
Importing every public name from a module using a wildcard ( from mymodule import * ) is a bad idea because: It could...
Read more >
Contract types — Import Linter 1.6.0 documentation
Wildcards (in the form of * ) are supported. These can stand in for a module names, but they do not extend to...
Read more >
New-AzADApplication (Az.Resources) - Microsoft Learn
Syntax; Description; Examples; Parameters; Outputs; Notes; RELATED LINKS ... Specifies whether this application supports device authentication without a ...
Read more >
Hibernate Search 6.1.7.Final: Reference Documentation
This allows the mapping of types that are not supported ... The usual compatibility policy does not apply: the contract of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found