usort/config.py
def with_first_party(self, filename: Path) -> "Config":
        """
        Infer first-party top-level names; this only works for the common case of
        a single package, but not multiple, or modules (pure-python or extensions).
        In those cases, you should explicitly set `known_first_party` in the config.

        This code as-is should work for something like running against a site-packages
        dir, but if we broaden to support multiple top-level names, it would find too
        much.

        To disable this code entirely, set `first_party_detection=false` in the config.
        """

        p = filename

        while True:
            # Stop on root (hopefully works on Windows)
            if p.parent == p:
                break
            # Stop on different volume
            if p.exists() and p.stat().st_dev != p.parent.stat().st_dev:
                break

            if (p.parent / "__init__.py").exists():
                p = p.parent
            else:
                break

        if (p / "__init__.py").exists():
            self.known[p.name] = CAT_FIRST_PARTY

        return self

        Infer first-party top-level names; this only works for the common case of
        a single package, but not multiple, or modules (pure-python or extensions).
        In those cases, you should explicitly set `known_first_party` in the config.

        This code as-is should work for something like running against a site-packages
        dir, but if we broaden to support multiple top-level names, it would find too
        much.

        To disable this code entirely, set `first_party_detection=false` in the config.
        
Infer first-party top-level names; this only works for the common case of
a single package, but not multiple, or modules (pure-python or extensions).
In those cases, you should explicitly set `known_first_party` in the config.

This code as-is should work for something like running against a site-packages
dir, but if we broaden to support multiple top-level names, it would find too
much.

To disable this code entirely, set `first_party_detection=false` in the config.
Infer first - party top - level names ; this only works for the common case of a single package but not multiple or modules ( pure - python or extensions ) . In those cases you should explicitly set ` known_first_party ` in the config . This code as - is should work for something like running against a site - packages dir but if we broaden to support multiple top - level names it would find too much . To disable this code entirely set ` first_party_detection = false ` in the config .
def with_first_party(self, filename: Path) -> "Config":
        p = filename
        while True:
            if p.parent == p:
                break
            if p.exists() and p.stat().st_dev != p.parent.stat().st_dev:
                break
            if (p.parent / "__init__.py").exists():
                p = p.parent
            else:
                break
        if (p / "__init__.py").exists():
            self.known[p.name] = CAT_FIRST_PARTY
        return self
def with_first_party ( self , filename : Path ) -> "Config" : p = filename while True : if p . parent == p : break if p . exists ( ) and p . stat ( ) . st_dev != p . parent . stat ( ) . st_dev : break if ( p . parent / "__init__.py" ) . exists ( ) : p = p . parent else : break if ( p / "__init__.py" ) . exists ( ) : self . known [ p . name ] = CAT_FIRST_PARTY return self
Infer first-party top-level names; this only works for the common case of
a single package, but not multiple, or modules (pure-python or extensions).
Infer first - party top - level names ; this only works for the common case of a single package but not multiple or modules ( pure - python or extensions ) .
"""
        Infer first-party top-level names; this only works for the common case of
        a single package, but not multiple, or modules (pure-python or extensions).
        In those cases, you should explicitly set `known_first_party` in the config.

        This code as-is should work for something like running against a site-packages
        dir, but if we broaden to support multiple top-level names, it would find too
        much.

        To disable this code entirely, set `first_party_detection=false` in the config.
        """ # Stop on root (hopefully works on Windows) # Stop on different volume
self
filename
Path